[Error]Null passed to a callee that requires a non-null argument

 现在代码中经常遇到如下警告

 [Error]Null passed to a callee that requires a non-null argument_第1张图片

 解决

// 这样声明的方法在控制器中调用后参数传nil时会报警告(Null passed to a callee that requires a non-null argument)

- (NSMutableArray *)arrayInitWithTxt:(NSString *)theTxt PictureArr:(NSArray *)thePictureArr VideoArr:(NSArray *)theVideoArr;


// 对声明参数添加属性(__nullable)时参数可传nil,传(__nonnull)时参数不能为空
- (NSMutableArray *)arrayInitWithTxt:(NSString * __nullable)theTxt PictureArr:(NSArray * __nullable)thePictureArr VideoArr:(NSArray * __nullable)theVideoArr;

TO:https://www.jianshu.com/p/3d030d367a34
 

你可能感兴趣的:([iOS]报错记录)