如何为XML元素体创建一个RestKit对象映射到对象属性?RestKit map XML元素体
XML:
<response>ok</response>
映射:
RKObjectMapping *responseMapping = [RKObjectMapping mappingForClass:[Response class]];
[responseMapping mapKeyPath:@"???" toAttribute:@"body"];
如何为XML元素体创建一个RestKit对象映射到对象属性?RestKit map XML元素体
XML:
<response>ok</response>
映射:
RKObjectMapping *responseMapping = [RKObjectMapping mappingForClass:[Response class]];
[responseMapping mapKeyPath:@"???" toAttribute:@"body"];
所以,如果你想在Response.body字符串 'OK'(谁是响应对象的属性):
[responseMapping mapKeyPath:@"response" toAttribute:@"body"];
它的工作原理?
非常好,谢谢。问题是我将对象映射到它自己的元素keypath。该'response'元素实际上是包裹在一个'result'元素: '
如果您在响应对象中有一个属性“响应”,如下所示: [responseMapping mapKeyPath:@“response”toAttribute:@“response”]; 你能详细介绍Response对象吗? – Beber 2012-02-08 16:50:16