iOS could not set nil as the value for the key
来源:互联网 发布:诈骗罪立案后网络追逃 编辑:程序博客网 时间:2024/06/04 19:23
从数据库中请求到的数据往往存在空值, 这时前台便无法处理数据, 赋值model属性的时候出现: could not set nil as the value for the key的报错.这时可用下列方式解决:
1. 在model的基类中重写setnilvalueforkey:
- (void)setNilValueForKey:(NSString *)key{ [self setValue:@"" forKey:key];}
2. 另外网上给出了另一个解决方案, 你如果使用网络请求类是AFN那么可以通过设置AFN中responseSerializer的removesKeysWithNullValues属性来规避空值
/** Whether to remove keys with `NSNull` values from response JSON. Defaults to `NO`. */@property (nonatomic, assign) BOOL removesKeysWithNullValues;
((AFJSONResponseSerializer *)session.responseSerializer).removesKeysWithNullValues
0 0
- iOS could not set nil as the value for the key
- could not set nil as the value for the key verifyStatus
- setNilValueForKey:could not set nil as the value for the key distance.解决方案
- iOS 错误"This class is not key value coding-compliant for the key"解决方案
- iOS: setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key name.
- iOS报错之this class is not key value coding-compliant for the key digitPressed.
- iOS setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key 问题
- iOS "this class is not key value coding-compliant for the key ..."问题的解决
- iOS Xcode 6报错:setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key v
- iOS遇到this class is not key value coding-compliant for the key tableView报错解决办法
- iOS- 报错(崩)[< > setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key
- The requested list key could not be resolved as a collection。。。。
- The requested list key 'deptlist' could not be resolved as a collection/array/map/enumeration/iterat
- The requested list key '#request.localprovi' could not be resolved as a collection/array/map/enumera
- The requested list key 'deptList' could not be resolved as a collection/array/map/enumeration/iterat
- 关于The requested list key 'map' could not be resolved as a collection/array/map/enumera...
- this class is not key value coding-compliant for the key
- this class is not key value coding-compliant for the key
- AI+情感+手机!卓易科技Freeme OS 7.0,有情感的操作系统
- JAVAjsp小程序流程
- USB HUB
- Linux Kernel(Android) 加密算法总结(一)(cipher、compress、digest)
- spring data jpa单个模型(单个表)分页
- iOS could not set nil as the value for the key
- realloc,malloc,calloc的区别
- Unity 判断当前网络类型
- Xcode 8.0注释的问题
- android 监听scrollview 滑动动作
- linux配置防火墙详细步骤(iptables命令使用方法)
- 配置samba服务器,中加入了security=share,但是testparm输出的信息里没有这一条,客户机也无法访问
- 自定义可滑动、可点击的开关
- Fragment之间数据传递的三种方式