iOS9新特性之泛型

//
//  ViewController.m
//  02-iOS9新特性之泛型
//
//  Created by kun on 16/8/16.
//  Copyright © 2016年 kun. All rights reserved.
//

/*
    泛型:限制类型
    为什么要推出泛型?迎合swift
    
    泛型作用:1,限制类型 2,提高代码规范,减少沟通成本
    泛型用法:类型<限制类型>
    泛型声明:在声明类的时候,在类的后面<泛型名称>
    泛型仅仅是报警告
    泛型好处:1,从数组中取出来可以使用点语法
            2,给数组添加元素有提示
    
    泛型在开发中使用场景:1,用于限制集合类型
    
    id是不能使用点语法
 
    为什么集合可以使用泛型?使用泛型,必须要声明泛型==>如何声明泛型
 
    自定义泛型
    什么时候使用泛型?在声明类的时候,不确定哪些属性或者方法类型,在使用这个类的时候才确定,就可以采用泛型
 
    如果没有定义泛型,默认就是id
 
 */

#import "ViewController.h"

@interface ViewController ()
@property (nonatomic, strong) NSMutableArray<NSString *> *arr;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
原文地址:https://www.cnblogs.com/fkunlam/p/5775117.html