美文网首页
nonnull、nullable、null_resettable

nonnull、nullable、null_resettable

作者: YotrolZ | 来源:发表于2016-11-21 11:20 被阅读54次

nonnull : 不能为空

  • 使用方法:
@property (nonatomic, copy, nonnull) NSString   *name1;
@property (nonatomic, copy) NSString * _Nonnull  name2;
@property (nonatomic, copy) NSString * __nonnull name3;
nonnull三种用法

nullable : 可以为空

  • 使用方法:
@property (nonatomic, copy, nullable)  NSString  *name1;
@property (nonatomic, copy) NSString *_Nullable  name2;
@property (nonatomic, copy) NSString *__nullable name3;
nullable三种方法

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

  • 使用方法:
@property (nonatomic, strong, null_resettable) NSString *name;
null_resettable使用方法.png

_Null_unspecified : 不确定是否为空

  • 使用方法:
@property (nonatomic, strong) NSString *_Null_unspecified  name1;
@property (nonatomic, strong) NSString *__null_unspecified name2;
_Null_unspecified2种方法.png

注意点:

不能修饰一般数据类型

不能修饰一般数据类型

相关文章

网友评论

      本文标题:nonnull、nullable、null_resettable

      本文链接:https://www.haomeiwen.com/subject/urhupttx.html