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
注意點(diǎn):
不能修飾一般數(shù)據(jù)類型
不能修飾一般數(shù)據(jù)類型