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

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

问题分析

此警告就是某属性不能为空,但你在某地方写了 xx = nil 冲突导致的

问题解决

在声明属性时加上 __nullable(?可以为空)与__nonnull(!不能为空)

如果放在@property里面的话不用写下划线,如:
@property (nonatomic, copy, nonnull) NSString * tickets;
@property (nonatomic, copy) NSString * __nonnull tickets;

__nullable指代对象可以为NULL或者为NIL
__nonnull指代对象不能为null

或者用宏NS_ASSUME_NONNULL_BEGIN和NS_ASSUME_NONNULL_END 包住多个属性全部具备nonnull,
所以在属性为空值时会报警告,只要声明一下属性的__nullable就好了,
例如:
-(NSString*)encoingWithDic:(NSMutableDictionary *__nullable)dataDic

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

推荐阅读更多精彩内容