可空修饰符
- nullable
- __nullable
- _Nullable
非空修饰符
- nonnull
- __nonnull
- _Nonnull
示例
@property (nonatomic, copy, nullable) NSString * p1;
@property (nonatomic, copy) NSString * __nullable p2;
@property (nonatomic, copy) NSString * _Nullable p3;
@property (nonatomic, copy) void (^p4) (NSInteger cmd, _Nullable id params, void (^ _Nullable callback) (id params));
- (nullable NSString *)m1;
- (NSString * __nullable)m2;
- (NSString * _Nullable)m3;
- (void)m4WithP:(nullable NSString *)p;
- (void)m5WithP:(NSString * _Nullable)p;
- (void)m6WithP:(NSString * __nullable)p;
- (void)m7WithBlock:(void(^_Nullable)(NSString * __nullable filePath, NSError * __nullable error))block;
// 双指针只能用带下划线的修饰符
- (void)functionWithError:(NSError * _Nullable * _Nullable)error;
// 默认非空的宏
NS_ASSUME_NONNULL_BEGIN
NS_ASSUME_NONNULL_END
NSObject 类型推荐使用不带下划线修饰符
Block,C方法 推荐使用带下划线的修饰符