Null passed to a callee that requires a non-null argument

这个警告是xcode6.3开始 为了让OC也能有swift的 ?和 !的功能,你在声明一个属性的时候加上 __nullable(?可以为空)与__nonnull(!不能为空) 如果放在@property里面的话不用写下划线

@property (nonatomic, copy, nonnull) NSString * title;
@property (nonatomic, copy) NSString * __nonnull subTitle;
@property (nonatomic, copy, nullable) NSString * title;
@property (nonatomic, copy) NSString * __nullable subTitle;

或者用宏NS_ASSUME_NONNULL_BEGIN和NS_ASSUME_NONNULL_END 包住多个属性全部具备nonnull,然后仅对需要nullable的改下就可以了。

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容