我需要有关嵌套对象映射的帮助,我想我遇到了一个bug。
当嵌套值是域(something.com)时,restkit会将其替换为嵌套属性,并尝试查找“something.com.name”,“something.com.url”,“something.com.email”假设2个嵌套,“某事”和“com”,因此失败。
以下是映射失败的日志:
2014-01-07 14:14:25.408 MyAppName[923:7003] D restkit.object_mapping:RKMapperOperation.m:231 Asked to map source object {
"myservice.co.tz" = {
countries = (
tz
);
flag = tz;
name = Tanzania;
url = "http://www.MyAppName.co.tz";
};
} with mapping <RKObjectMapping:0x15591b20 objectClass=LMCountry propertyMappings=(
"<RKAttributeMapping: 0x15591e10 <RK_NESTING_ATTRIBUTE> => host>",
"<RKAttributeMapping: 0x15591f80 (host).name => name>",
"<RKAttributeMapping: 0x15592030 (host).currency => currency>",
"<RKAttributeMapping: 0x155921b0 (host).flag => flag>",
"<RKAttributeMapping: 0x155921f0 (host).url => url>",
"<RKAttributeMapping: 0x15591ee0 (host).countries => countries>"
)>
2014-01-07 14:14:25.411 MyAppName[923:7003] D restkit.object_mapping:RKMappingOperation.m:952 Starting mapping operation...
2014-01-07 14:14:25.415 MyAppName[923:7003] T restkit.object_mapping:RKMappingOperation.m:953 Performing mapping operation: <RKMappingOperation 0x155a4600> for 'LMCountry' object. Mapping values from object {
"MyAppName.co.tz" = {
countries = (
tz
);
flag = tz;
name = Tanzania;
url = "http://www.MyAppName.co.tz";
};
} to object <LMCountry: 0x155a60f0> with object mapping (null)
2014-01-07 14:14:25.418 MyAppName[923:7003] D restkit.object_mapping:RKMappingOperation.m:914 Found nested mapping definition to attribute 'host'
2014-01-07 14:14:25.420 MyAppName[923:7003] D restkit.object_mapping:RKMappingOperation.m:917 Found nesting value of 'MyAppName.co.tz' for attribute 'host'
2014-01-07 14:14:25.422 MyAppName[923:7003] T restkit.object_mapping:RKMappingOperation.m:550 Mapping attribute value keyPath '<RK_NESTING_ATTRIBUTE>' to 'host'
2014-01-07 14:14:25.424 MyAppName[923:7003] T restkit.object_mapping:RKMappingOperation.m:572 Mapped attribute value from keyPath '<RK_NESTING_ATTRIBUTE>' to 'host'. Value: MyAppName.co.tz
2014-01-07 14:14:25.427 MyAppName[923:7003] T restkit.object_mapping:RKMappingOperation.m:605 Skipping attribute mapping for special keyPath '<RK_NESTING_ATTRIBUTE>'
2014-01-07 14:14:25.429 MyAppName[923:7003] T restkit.object_mapping:RKMappingOperation.m:617 Did not find mappable attribute value keyPath 'MyAppName.co.tz.name'
2014-01-07 14:14:25.431 MyAppName[923:7003] T restkit.object_mapping:RKMappingOperation.m:617 Did not find mappable attribute value keyPath 'MyAppName.co.tz.currency'
2014-01-07 14:14:25.433 MyAppName[923:7003] T restkit.object_mapping:RKMappingOperation.m:617 Did not find mappable attribute value keyPath 'MyAppName.co.tz.flag'
2014-01-07 14:14:25.435 MyAppName[923:7003] T restkit.object_mapping:RKMappingOperation.m:617 Did not find mappable attribute value keyPath 'MyAppName.co.tz.url'
2014-01-07 14:14:25.437 MyAppName[923:7003] T restkit.object_mapping:RKMappingOperation.m:617 Did not find mappable attribute value keyPath 'MyAppName.co.tz.countries'
2014-01-07 14:14:25.439 MyAppName[923:7003] D restkit.object_mapping:RKMappingOperation.m:1021 Finished mapping operation successfully...
答案 0 :(得分:1)
您不能(至少在撰写本文时)使用addAttributeMappingFromKeyOfRepresentationToAttribute
,其中关联的数据将包含点,因为数据稍后用作键,点将其更改为键路径。这就是键路径导航错误发生的原因。
2个可能的选择:
valueForKey:
)