iOS9 新特性关键字(一)

来源:互联网 发布:怎么查询计算机端口号 编辑:程序博客网 时间:2024/05/16 00:38

/*

 nullable作用:表示可以为空

 nullable书写规范:

 // 方式一:

 @property (nonatomic, strong, nullable) NSString *name;

 // 方式二:

 @property (nonatomic, strong) NSString *_Nullable name;

 // 方式三:

 @property (nonatomic, strong) NSString *__nullable name;

 

 */

//@property (nonatomic, strong) NSString *__nullable name;

//@property (nonatomic, strong) NSString * name;


/*

 nonnull: non: null:


    书写格式:

 @property (nonatomic, strong, nonnull) NSString *icon;

 

 @property (nonatomic, strong) NSString * _Nonnull icon;

 

 @property (nonatomic, strong) NSString * __nonnull icon;

 

 */


/*

  NS_ASSUME_NONNULL_BEGINNS_ASSUME_NONNULL_END之间,定义的所有对象属性和方法默认都是nonnull

 */


// 方法中,关键字书写规范

/**

- (nonnull NSString *)test:(nonnull NSString *)str;

- (NSString * _Nonnull)test1:(NSString * _Nonnull)str;

*/


//@property (nonatomic, assign) int age;


/*

 null_resettable: get:不能返回为空, set可以为空

 // 注意;如果使用null_resettable,必须重写get方法或者set方法,处理传递的值为空的情况

 // 书写方式:

 @property (nonatomic, strong, null_resettable) NSString *name;

 */



/*

    _Null_unspecified:不确定是否为空

    书写方式只有这种

    方式一

    @property (nonatomic, strong) NSString *_Null_unspecified name;

    方式二

    @property (nonatomic, strong) NSString *__null_unspecified name;

 */





@end


@implementation ViewController


//- (void)setName:(NSString *)name

//{

//    if (name == nil) {

//        name = @"123";

//    }

//    _name = name;

//}

//- (NSString *)name

//{

//    if (_name == nil) {

//        _name = @"123";

//    }

//    return _name;

//}


// iOS9新出的关键字:用来修饰属性,或者方法的参数,方法的返回值

// 好处:

// 1.迎合swift

// 2.提高我们开发人员开发规范,减少程序员之间交流


// 注意:iOS9新出关键字nonnull,nullable只能修饰对象,不能修饰基本数据类型

//- (UIView *)view

//{

//    if (_view == nil) {

//        [self loadView];

//        [self viewDidLoad];

//    }

//    

//    return _view;

//}


0 0
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 employee 拼音转数字 JAVA拼音转数字 C加密字符串 日本女优无码下载迅雷 定义一个字符串类String,实现判断该字符串是否为回文字符串 字符串类String回文字符串 判断字符串是否为回文字符串 RRC ERAB E-RAB Linux用gred命令单词长度大于等于5 使用重定向命令完成2个文件合并 使用重定向完成文本文件的拷贝 Linux查找时候不现实出错信息 Linux去掉某个文件所有者同组用户的写权限 求方程式ax2 GNAB-011 flash制作课件 有数组$array=array(“a”=>2,”b”=>6,”c”=>5) 有数组$array=array(“a”=>2,”b”=>6,”c”=>5) 有数组$array=array(“a”=>2,”b”=>6,”c”=>5)排序 php对一个数组按某个键值排序 有数组$array=array(“a”=>2,”b”=>6,”c”=>5);用php实现对以上数组进 $array=array(“a”=>2,”b”=>6,”c”=>5);用php实现对以上数组大小排序 $array=array(“a”=>2,”b”=>6,”c”=>5) $array=array(“a”=>2,”b”=>6,”c”=>5)排序 Linux去掉某个文件所有者同组用户的写权限 Linux.sed命令显示某个文件的第五行 Linux输出该文件的奇数行 Linuxsed命令在文件的最后一行插入该文件的的统计信息,包含多少行,多少个单词,多个字符 Linuxcut命令 Linux.cut命令 Linux.cut命令提出a文件中 Linux.cut命令提出a文件中 Linux.ls Linux创建文件 Linux修改文件的时间 Linux创建文件 Linux修改文件的时间 数字图像分析