iOS MJExtension 字典“id”转model
2019-10-14 本文已影响0人
tongyuling
一、model.h里直接添加如下会有问题:
@property (nonatomic,copy)NSString * id;
应该改为:
@property (nonatomic,copy)NSString * xxx_id;
二、model.m里直接添加如下:
+ (NSDictionary *) mj_replacedKeyFromPropertyName
{
return @{@"xxx_id" : @"id"};
}
三、直接调用就可以了,如下:
Model *model = [Model mj_objectWithKeyValues:dict];