iOS 9新特性

来源:互联网 发布:离线翻译软件 知乎 编辑:程序博客网 时间:2024/05/01 13:16

/*

 *iOS 9新的关键字用来修饰属性或者方法的参数 方法的返回值

 * 只能修饰对象 不能修饰基本数据类型

 *nullable   可以为空

 *nonnull  不可以为空 非空

 *null_resettable    get不能返回空  set可以为空

 //null_resettable 必须重写get方法或者set方法,处理传递的值为空的情况

 

 

 _Null_unspecified 不确定是否为空

 

 **/


//第一种方式

//@property(nonatomic,strong,nullable)NSArray *dataSoure;


//第二种方式


//@property(nonatomic,strong)NSArray *_Nullable dataSoure;


//第三种方式


@property(nonatomic,strong)NSArray *__nullable datasource;








泛型




#import "NewViewController.h"


@interface NewViewController ()


@property(nonatomic,strong)NSMutableArray<NSString*>  *datas;



@end


@implementation NewViewController

/**

 泛型 限制类型

 

 泛型使用的场景

 1 在集合(数组,字典, NSSet)中使用泛型比较常见

 

 泛型好处

 1提高开发的规范 减少程序员之间交流

 2通过集合取出对象直接当做泛型对象使用可以直接使用.语法

 

 

 泛型修饰 只能修饰方法的调用

 

 

 

 

 */

 

-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{

    [supertouchesBegan:touches withEvent:event];

    

}

- (void)viewDidLoad {

    [superviewDidLoad];

    // Do any additional setup after loading the view.

    

}






__kindof


#import "KindViewController.h"


@interface KindViewController ()


@end

/**

 __kindof :表示当前类或者它的子类

 */


@implementation KindViewController


- (void)viewDidLoad {

    [superviewDidLoad];

 

    

    // Do any additional setup after loading the view.

}


- (void)didReceiveMemoryWarning {

    [superdidReceiveMemoryWarning];

    // Dispose of any resources that can be recreated.

}


/*

#pragma mark - Navigation


// In a storyboard-based application, you will often want to do a little preparation before navigation

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

    // Get the new view controller using [segue destinationViewController].

    // Pass the selected object to the new view controller.

}

*/


@end






0 0
原创粉丝点击