在RestKit中映射响应数据

时间:2016-10-22 07:03:16

标签: ios iphone restkit

我在项目中使用了restkit,我正在尝试映射json数据。

响应数据格式来自json GET webservice is:

    [
      {
         "Id":"XXXX",
         "detailId":"XXXX",
         "OriginalTitle":"XXXX"
      },
      {
         "Id":"XXXX,
         "detailId":"XXXX",
         "OriginalTitle":"XXXX"
       }
    ]

如何使用任何键映射数据。

一般情况下我用下面的地图

     RKObjectMapping *objectMapping = [RKObjectMapping mappingForClass:[self class]];
     [objectMapping addAttributeMappingsFromDictionary:@{@"status":@"strStatus",
@"message":@"strMessage"}]; 

     [objectMapping addPropertyMapping:[RKRelationshipMapping relationshipMappingFromKeyPath:@"***MyKeyfromAPI***" toKeyPath:@"MyArrayVariableInProject" withMapping:[***SomeModelClass*** mapping]]];

错误类似于:

[request=1.0424s mapping=0.0000s total=1.2667s]: Error Domain=org.restkit.RestKit.ErrorDomain Code=1001 "No response descriptors match the response loaded." 
{Error Domain=org.restkit.RestKit.ErrorDomain Code=1001 "No mappable object representations were found at the key paths searched." UserInfo={NSLocalizedDescription=No mappable object representations were found at the key paths searched., NSLocalizedFailureReason=The mapping operation was unable to find any nested object representations at the key paths searched: 
This likely indicates that you have misconfigured the key paths for your mappings., keyPath=null, DetailedErrors=(
)}}, keyPath=null, NSLocalizedDescription=No response descriptors match the response loaded.}

但在响应中我有任何数组键。 我该如何映射这个。请帮忙。

0 个答案:

没有答案
相关问题