model中带数组的情况
#import <Mantle/Mantle.h>
#import "MantleModelCommonHeader.h"
#import "MessageModel.h"
@interface MessageListModel : MTLModel <MTLJSONSerializing>
@property (nonatomic, strong) NSMutableArray *messageArray; // 赞数组
@property (nonatomic, strong) NSString *lastId; // 最后一条的ID
@end
#import "MessageListModel.h"
@implementation MessageListModel
/**
* 将JSON字典中键对应的值,赋值给属性值
*/
+ (NSDictionary *)JSONKeyPathsByPropertyKey{
return @{
//前面是属性,后面是JSON的key
@"messageArray": @"list",
@"lastId": @"last_id",
};
}
#pragma mark - 特殊字段的处理方法回调函数
+ (NSValueTransformer *)messageArrayJSONTransformer{
return [MTLValueTransformer transformerUsingForwardBlock:^id(id value, BOOL *success, NSError *__autoreleasing *error) {
NSArray *jsonArray