美文网首页
Null passed to a callee that req

Null passed to a callee that req

作者: 拂溪 | 来源:发表于2019-11-03 11:11 被阅读0次

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

相关文章

网友评论

      本文标题:Null passed to a callee that req

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