在用于将类映射到我们使用JSON键值的RestKit中,
RKObjectMapping * userMapping = [RKObjectMapping mappingForClass:[User class]];
[userMapping mapKeyPath:@"PrimaryKey" toAttribute:@"id"];
[[RKObjectManager sharedManager].mappingProvider setMapping:usereMapping forKeyPath:@"clientUser"];然而,在android中,如果使用restlet,我们只需在类中声明变量时添加@JsonProperty("PrimaryKey"),。并完成键值映射。
对于类似android restlet?的iOS restkit,有没有更简单的方法
提前谢谢。
发布于 2013-05-06 20:01:03
你可以在ios中这样做
RKObjectMapping* articleMapping = [RKObjectMapping mappingForClass:[Article class]];
[articleMapping addAttributeMappingsFromDictionary:@{
@"title": @"title",
@"body": @"body",
@"author": @"author",
@"publication_date": @"publicationDate"
}];和
// Create our new Author mapping
RKObjectMapping* authorMapping = [RKObjectMapping mappingForClass:[Author class] ];
// NOTE: When your source and destination key paths are symmetrical, you can use addAttributesFromArray: as a shortcut instead of addAttributesFromDictionary:
[authorMapping addAttributeMappingsFromArray:@[ @"name", @"email" ]];https://stackoverflow.com/questions/16398139
复制相似问题