JSONModel
2016-08-16 本文已影响27人
227f600b867c
如果有一个数组,且数组里包含的是自定义的对象类型,则一定要在该类前实现名为所包含对象类型的协议,且NSArray<XXImage> 括号内没有 ‘ * ’
@protocol XXImage
@end
@protocol XXPicture
@end
@interface XXModel : JSONModel
@property (nonatomic, copy) NSString *id;
@property (nonatomic, copy) NSString *name;
@property (nonatomic, copy) NSString *address;
@property (nonatomic, strong) NSArray<XXImage> *images;
@property (nonatomic, strong) NSArray<XXPicture> *pictures;
@end
给所有property加<optional>,在该类的.m里添加如下代码:
+ (BOOL)propertyIsOptional:(NSString *)propertyName{
return YES;
}
别的没什么好说的了