【发布时间】:2012-01-14 06:06:06
【问题描述】:
如果我有这样的 JSON 响应,映射应该是什么样子:
{
"persons":{
"@size":"4",
"person":[
{
"name":"John",
"type":"Doe 1",
"options":"some options"
},
{
"name":"John",
"type":"Doe 2",
"options":"some other options"
},
{
"name":"John",
"type":"Doe 3",
},
{
"name":"John",
"type":"Doe 4",
}
]
}
}
我已经尝试了以下映射,但它不起作用:
RKManagedObjectMapping* personMapping = [RKManagedObjectMapping mappingForClass:[CDCustomFieldDefinition class]];
[personMapping mapKeyPath:@"label" toAttribute:@"label"];
[personMapping mapKeyPath:@"type" toAttribute:@"type"];
[personMapping mapKeyPath:@"options" toAttribute:@"options"];
personMapping.primaryKeyAttribute = @"label";
[[RKObjectManager sharedManager].mappingProvider setMapping:personMapping forKeyPath:@"persons"];
didLoadObjects: 中的对象数组始终为空...有什么想法吗?非常感谢!
【问题讨论】:
标签: objective-c ios mapping restkit