[<ProductModel 0x7a607340> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key id.
原因为在进行kvc操作是 字典中的key不存在对应模型属性
@interface ProductModel : NSObject
@property(nonatomic,copy)NSString *icon;
@property(nonatomic,copy)NSString *title;
-(instancetype)initWithDict:(NSDictionary *)dict;
"title": "网易公开课",
"id": "com.netease.videoHD",
"url": "http://itunes.apple.com/app/id415424368?mt=8",
"icon": "open@2x.png",
"customUrl": "ntesopen"
所以错误在
@implementation ProductModel
-(instancetype)initWithDict:(NSDictionary *)dict{
if (self=[super init]) {
[self setValuesForKeysWithDictionary:dict]; !!!!!!!!!错误在此处!!!!!!!
}
return self;
}
@end
解决方法:
-(instancetype)initWithDict:(NSDictionary *)dict{
if (self=[super init]) {
self.icon=dict[@"icon"];
self.title=dict[@"title"];
}
return self;
}