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

好处:1.迎合swift

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

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

nullable : 修饰的对象可以为空

书写方式:

1.@property (nonatomic , strong) NSString * __nullable company;

2.@property (nonatomic , strong , nullable) NSString *company;

3.@property (nonatomic , strong ) NSString *_Nullable company;

nonnull  : 修饰的对象不可以为空

书写方式:

1.@property (nonatomic , strong) NSString * __nonnull company;

2.@property (nonatomic , strong , nonnull) NSString *company;

3.@property (nonatomic , strong ) NSString *_Nonnull company;

null_resettable  : set方法参数可以为空,get方法返回值不能为空,用孩关键字修饰的对象,必须重写set或get方法处理为空情况

书写方式:只有这一种方式

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

-(NSString *)company

{

if (_company == nil) {

_company = @"1";

}

return _company;

}

-(void)setCompany:(NSString *)company

{

if (company == nil) {

company = @"1";

}

}

null_unspecified  : 不确定是否为空

书写方式:

1.@property (nonatomic , strong , null_unspecified) NSString *company;

2.@property (nonatomic , strong ) NSString * __null_unspecified company;

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

NS_ASSUME_NONNULL_BEGIN  : 宏区间,在这个区域里的对象、方法的参数或返回值都不能为空

NS_ASSUME_NONNULL_END

书写方式:

NS_ASSUME_NONNULL_BEGIN

@property (nonatomic ) NSString *name;

@property (nonatomic , assign ) int age;

-(NSString *)getStr:(NSString *)str;

NS_ASSUME_NONNULL_END

最新文章

  1. css3圆形百分比进度条的实现原理
  2. JVM加载类的过程,双亲委派机制中的方法
  3. C#算法之判断一个字符串是否是对称字符串
  4. 关于JavaScript中的创建对象的学习总结
  5. Redhat=》中文
  6. Sqlserver更新数据表xml类型字段内容某个节点值的脚本
  7. JAVA 线程学习 - Thread了解
  8. jQuery的ajax对WebApi和OData的封装
  9. 用ildasm和ilasm对.net下的exe程序进行破解初探
  10. SmartCode 使用常见问题
  11. 彻底解决CDH5.12安装过程中 Error: JAVA_HOME is not set and Java could not be found
  12. loadrunner笔记(三):设置、运行场景和生成测试报告
  13. 擦他丫的,今天在Django项目中引用静态文件jQuery.js 就是引入报错,终于找到原因了!
  14. mongodb分片balance
  15. IOS高访微信聊天对话界面(sizeWithFont:constrainedToSize和stretchableImageWithLeftCapWidth的使用)
  16. vba的一个File操作类
  17. PHP实现双向链表、栈
  18. c# winform使用IrisSkin2换肤弹不出窗口解决方案
  19. 10.20 olinr
  20. ps_cc:制作sprite拼贴图片

热门文章

  1. K3Cloud调用存储过程
  2. chef and churu 分块 好题
  3. luogu 1354 房间最短路问题 线段与直线相交 最短路
  4. 转 Python爬虫实战二之爬取百度贴吧帖子
  5. ListView列表刷新方法的区别
  6. jquery 分页功能
  7. 找小于N 的所有质数
  8. 分享Kali Linux 2017年第12周镜像文件
  9. JVM 常用命令
  10. 调用tensorflow中的concat方法时Expected int32, got list containing Tensors of type '_Message' instead.