0
{
"JobID" : "aaaabbbb-dddd-eeee-ffff-aaaabbbbcccc",
"UserID": "11112222-dddd-eeee-ffff-111122223333",

"FolderVersions" :  [
                {
                    "FolderID" : "11112222-dddd-eeee-ffff-111122223333",
                    "Version" : "1.0"
                },
                {
                    "FolderID" : "11113333-dddd-eeee-ffff-111122223333",
                    "Version" : "1.2"
                },
                {
                    "FolderID" : "33332222-dddd-eeee-ffff-111122223333",
                    "Version" : "1.1"
                }
            ]
}

我有带有 jobid、userid 和 nsmutable_array “folderversion”的作业类

FolderVersions:使用具有 folder_id 和 version 的 FolderVersion 类进行映射

我希望将 FolderVersions 映射到作业类中的 folderversion 数组

RKObjectMapping *jobMapping = [RKObjectMapping mappingForClass:[Job class]];
[jobMapping addAttributeMappingsFromDictionary:@{
 @"JobID" : @"jobId",@"USerID":@"userID"
      }];



    RKObjectMapping *folderMapping = [RKObjectMapping mappingForClass:[FolderVersion class]];
    [folderMapping addAttributeMappingsFromDictionary:@{@"FolderID":@"folderID",

 @"Version":@"version",

 }];



    RKResponseDescriptor *responseDescripor1 = [RKResponseDescriptor jobMapping
         method:RKRequestMethodPOST pathPattern:@"/xxx/response.php/json/response" 

keyPath:nil statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)];
4

1 回答 1

1

您需要向您的 中添加关系映射jobMapping,该映射将类中的键链接到JobJSON ( FolderVersions) 中的键,并指定它应该将folderMapping用于内容:

[jobMapping addPropertyMapping:[RKRelationshipMapping relationshipMappingFromKeyPath:@"FolderVersions" toKeyPath:@"folderversion" withMapping:folderMapping]];
于 2013-07-27T12:26:24.943 回答