JsonModel可以直接把json数据转换成model,字典转model不用说,很easy,但是最近遇到一个坑,就是字典套数组的时候转化成model,就是取不出来数据。
model如下:
@interface OWOChatRoomListMdoel : OWORespBaseModel@property(nonatomic,strong)NSArray*result;
@end
@interface ChatRoomModel : OWOBaseModel
@property(nonatomic,assign)int roomId;
@property(nonatomic,copy)NSString *chatroomId;
@property(nonatomic,assign)long ownerUid;
@property(nonatomic,copy)NSString *ownerEasemodId;
@property(nonatomic,copy)NSString *ownerNickname;
@property(nonatomic,copy)NSString *icon;
@property(nonatomic,copy)NSString *name;
@property(nonatomic,assign)int impressNum;
@property(nonatomic,assign)int affiliationsNum;
@property(nonatomic,assign)int totalNum;
@property(nonatomic,assign)BOOL status;
@end
这是一个字典套数组的model,我用JsonModel转化时,各种不成功,报类型错误,也检查不出错误来,查阅资料发现,JsonModel在字典套数组这种数据转化时,数组的字典model必须得申明一个协议(内部是用协议加属性的。。)
@protocol ChatRoomModel
@end
加条协议,注意必须和数组的model类一样,好坑,特此记一笔留念~O~O~!