我有一个问题:latest_update字段在 JSON数据的映射。RestKit - “高级数据对象”的对象映射问题?
从我的web Recieving这个JSON数据:
{"Places":[
{"place_ID": "7cceedda-ed3a-11e0-a1a8-858e3974979a",
"timestamp": "2011-10-02 23:24:42"
},
{"place_ID": "7cceedda-ed3a-11e0-a1a8-858e3974933x",
"timestamp": "2011-10-02 23:24:42"
},
{"latest_update":"2011-10-13 12:16:17"}]
}
而我使用的管理映射代码剪断:
//Place mapping
if (!self.placeManagedObject){
self.placeManagedObject = [RKManagedObjectMapping
mappingForClass:[Place class]];
self.placeManagedObject.primaryKeyAttribute = @"UUID";
self.placeManagedObject.rootKeyPath = @"places";
[self.placeManagedObject mapKeyPath:@"place_ID"
toAttribute:@"UUID"];
[self.placeManagedObject mapKeyPath:@"timestamp"
toAttribute:@"timestamp"];
[self.placeManagedObject mapRelationship:@"PlaceInformation"
withMapping:self.placeInfoManagedObject];
// Register mapping with the provider - means it will look for
places in the JSON input
[objectManager.mappingProvider
setMapping:self.placeManagedObject forKeyPath:@"places"];
}
//latestDBUpdate timestamp mapping
if (!self.latestDBUpdateManagedObject){
self.latestDBUpdateManagedObject = [RKManagedObjectMapping
mappingForClass:[LatestDBUpdate class]];
self.latestDBUpdateManagedObject.primaryKeyAttribute =
@"latest_update";
self.latestDBUpdateManagedObject.rootKeyPath = @"places";
[self.latestDBUpdateManagedObject mapKeyPath:@"latest_update"
toAttribute:@"latest_update"];
// Register mapping with the provider - means it will look for
places in the JSON input
[objectManager.mappingProvider
setMapping:self.latestDBUpdateManagedObject
forKeyPath:@"latest_update"];
}
RestKit将映射位置目标正确即: {“place_ID”:“7cceedda-ed3a-11e0-a1a8-858e3974979a”, “timestamp”:“2011-10-02 23:24:42” } ... 到位对象, 但latest_update没有被映射到 LatestDBUpdate类对象,我不能以任何方式得到它的工作。
我希望有人可以回答它是如何完成的,因为搜寻和尝试的小时数已经让我没有接近解决方案。 Thanx Thomas