我正在使用 RestKit 0.20 并在使用带有点 (.) 的规范符号时检测到一种奇怪的映射行为。如果您能解释一种简单的方法来处理从我在 IOS 上作为 NSManagedObject 实现的扁平对象到服务器端的对象关系的对象映射,我会很高兴。
映射几乎是正确的,但从我的角度来看,将 geopoint.lat 和 geopoint.lon 映射为额外字段是错误的,并且会在服务器上引发异常(无法识别的属性异常)。
RKObjectMapping:
[mapping addAttributeMappingsFromDictionary:@{
@"geopoint.lat": @"latitude",
@"geopoint.lon": @"longitude",
@"countrycode": @"countryId",
@"county": @"county",
@"postcode": @"postalcode",
@"city": @"city",
@"street": @"street",
@"housenumber": @"housenumber"
}];
有效结果(显示为日志输出)
2013-01-29 09:29:38.856 CPlusApp[4285:907] T restkit.object_mapping:RKMappingOperation.m:514 Mapped relationship object from keyPath 'startAddress' to 'startAddress'. Value: {
city = aCity;
geopoint = {
lat = "48.8901234";
lon = "8.818448999999998976";
};
"geopoint.lat" = "48.8901234";
"geopoint.lon" = "8.818448999999998976";
postcode = 91000;
street = Rennbrunnen;
}
2013-01-29 09:29:38.861 CPlusApp[4285:907] D restkit.object_mapping:RKMappingOperation.m:818 Finished mapping operation successfully...