我有以下 Mantle 对象并想将字典转换为 Mantle 对象。但转换总是返回空的 MTLModel 对象。有任何想法吗?
//ABC.h
@interface ABC : MTLModel<MTLJSONSerializing>
@property (nonatomic, strong) NSString *Identifier;
@property (nonatomic, strong) NSString *Name;
@property (nonatomic, strong) NSString *ImageURLString;
@property (nonatomic, strong) NSString *Desc;
@property (nonatomic, strong) NSString *lastUpdated;
@end
// ABC.m
@implementation ABC
+ (NSDictionary *)JSONKeyPathsByPropertyKey {
return @{
@"Identifier" : @"id",
@"Name" : @"name",
@"Desc" : @"desc",
@"ImageURLString" : @"image_url",
@"lastUpdated" : @"last_updated_at"
};
}
@end
调用代码:
ABC *abc = [MTLJSONAdapter modelOfClass:ABC.class fromJSONDictionary:tempDict error:NULL];
JSON字典是:
{
desc = "asdadasdakjqewqwmsdnasdaksdasd";
id = adsasdasdasdasd;
"image_url" = "http://upload.wikimedia.org/wikipedia/commons/thumb/1/19/abc.JPG";
"last_updated_at" = "2015-07-25 04:22:39.851710";
name = asdasdqwe;
}
结果 ABC 对象没有内容。无法弄清楚我在这里缺少什么。
有任何想法吗???