- (instancetype)initWithDic:(NSDictionary *)dic{
self = [super init];
if (self) {
[self setValuesForKeysWithDictionary:dic];
}
return self;
}
// 容错方法一:
// 接口中有的属性,model中没有全写
- (void)setValue:(id)value forUndefinedKey:(NSString *)key{
}
// 容错方法二:
// model里写的属性,接口中没有
//- (id)valueForUndefinedKey:(NSString *)key{
//
//}
// 使用
for (NSDictionary *dic in arr) {
listModel *model = [[listModel alloc] initWithDic:dic];
[self.myArr addObject:model];
}