Objective c Restkit返回0个键值对的对象数组

Objective c Restkit返回0个键值对的对象数组,objective-c,restkit,Objective C,Restkit,我不确定我错过了什么。对于这个请求,我得到一个关键路径为“data.file”的JSON响应。响应描述符设置如下: [fileMapping addAttributeMappingsFromDictionary:@{@"parentPath" : @"parentPath"}]; RKResponseDescriptor *fileResponseDescriptorFile = [RKResponseDescriptor responseDescriptorWithMapping:f

我不确定我错过了什么。对于这个请求,我得到一个关键路径为“data.file”的JSON响应。响应描述符设置如下:

[fileMapping addAttributeMappingsFromDictionary:@{@"parentPath" : @"parentPath"}];

RKResponseDescriptor *fileResponseDescriptorFile =
    [RKResponseDescriptor responseDescriptorWithMapping:fileMapping
                    method:RKRequestMethodAny
               pathPattern:nil
                   keyPath:@"data.file"
               statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)]; 
getObjectsAtPath
调用的success块被触发,从那里映射
结果。array
显示一个对象数组,但没有键值对

如果我手动反序列化JSON,就会正确填充键值对

NSDictionary* json = [NSJSONSerialization JSONObjectWithData:operation.HTTPRequestOperation.responseData options:NSJSONReadingMutableContainers error:nil];
        NSDictionary *data=[json objectForKey:@"data"];
        NSArray *files = [data objectForKey:@"file"];
        NSLog(@"files: %@", files);
以下是JSON的一个片段:

{
"data": {
    "folder": [
        {
            "parentPath": "xxx",
            "name": "xxx",
            "versionCreated": "2015-12-11T19:26:19.782Z"
        }
    ],
    "file": [
        {
            "parentPath": "xxx",
            "name": "2015-09-18 104310-4377094.JPG",
            "size": 4377094,
            "checksum": "5988e769689095c6512a3b5382e92677e0aa495b8a2d71506d3ca24b561f2dff",
            "contentToken": "xxx",
            "versionCreated": "2015-09-18T14:53:36.525Z",
            "version": 1,
            "systemAttributes": {
                "Capture-Date": "2015-09-18T14:43:10.000Z",
                "Geo-Latitude": 40.00000,
                "Geo-Longitude": -74.00000,
                "Height": 3024,
                "Mime-Type": "image/jpeg",
                "Orientation": 6,
                "Timeline-Date": "2015-09-18T14:43:10.000Z",
                "Width": 4032
            }
        }...
Restkit日志记录:

CloudAPIRestKit[86320:8464807] D restkit.object_mapping:RKMapperOperation.m:414 Executing mapping operation for representation: {
    data =     {
        file =         (
                        {
                checksum = xxx;
                contentToken = "xxx-gmkQ4oOO1c~";
                name = "2015-09-18 104310-4377094.JPG";
                parentPath = "/xxx";
                size = 4377094;
                systemAttributes =                 {
                    "Capture-Date" = "2015-09-18T14:43:10.000Z";
                    "Geo-Latitude" = "40.00000";
                    "Geo-Longitude" = "-74.00000";
                    Height = 3024;
                    "Mime-Type" = "image/jpeg";
                    Orientation = 6;
                    "Timeline-Date" = "2015-09-18T14:43:10.000Z";
                    Width = 4032;
                };
                version = 1;
                versionCreated = "2015-09-18T14:53:36.525Z";
            },...

} with mapping <RKObjectMapping:0x7fa958654190 objectClass=CloudFileModel propertyMappings=(
    "<RKAttributeMapping: 0x7fa958729b60 parentPath => parentPath>",
    "<RKAttributeMapping: 0x7fa958654500 name => name>"
)>
2016-01-18 09:50:31.262 CloudAPIRestKit[86320:8464807] D restkit.object_mapping:RKMappingOperation.m:1172 Starting mapping operation...
2016-01-18 09:50:31.263 CloudAPIRestKit[86320:8464807] T restkit.object_mapping:RKMappingOperation.m:1173 Performing mapping operation: <RKMappingOperation 0x7fa958696100> for 'CloudFileModel' object. Mapping values from object {
    checksum = xxx;
    contentToken = "xxx-xxx~";
    name = "2015-09-18 104310-4377094.JPG";
    parentPath = "/xxx";
    size = 4377094;
    systemAttributes =     {
        "Capture-Date" = "2015-09-18T14:43:10.000Z";
        "Geo-Latitude" = "40.00000";
        "Geo-Longitude" = "-74.00000";
        Height = 3024;
        "Mime-Type" = "image/jpeg";
        Orientation = 6;
        "Timeline-Date" = "2015-09-18T14:43:10.000Z";
        Width = 4032;
    };
    version = 1;
    versionCreated = "2015-09-18T14:53:36.525Z";
} to object <CloudFileModel: 0x7fa95a822d70> with object mapping (null)
2016-01-18 09:50:31.264 CloudAPIRestKit[86320:8464807] T restkit.object_mapping:RKMappingOperation.m:693 Found transformable value at keyPath 'parentPath'. Transforming from class '__NSCFString' to 'NSString'
2016-01-18 09:50:31.265 CloudAPIRestKit[86320:8464807] T restkit.object_mapping:RKMappingOperation.m:712 Mapping attribute value keyPath 'parentPath' to 'parentPath'
2016-01-18 09:50:31.265 CloudAPIRestKit[86320:8464807] T restkit.object_mapping:RKMappingOperation.m:728 Mapped attribute value from keyPath 'parentPath' to 'parentPath'. Value: /VZMOBILE/Cellco Test’s iPhone
2016-01-18 09:50:31.266 CloudAPIRestKit[86320:8464807] T restkit.object_mapping:RKMappingOperation.m:693 Found transformable value at keyPath 'name'. Transforming from class '__NSCFString' to 'NSString'
2016-01-18 09:50:31.266 CloudAPIRestKit[86320:8464807] T restkit.object_mapping:RKMappingOperation.m:712 Mapping attribute value keyPath 'name' to 'name'
2016-01-18 09:50:31.267 CloudAPIRestKit[86320:8464807] T restkit.object_mapping:RKMappingOperation.m:728 Mapped attribute value from keyPath 'name' to 'name'. Value: 2015-09-18 104310-4377094.JPG
2016-01-18 09:50:31.267 CloudAPIRestKit[86320:8464807] D restkit.object_mapping:RKMappingOperation.m:1273 Finished mapping operation successfully...
2016-01-18 09:50:31.268 CloudAPIRestKit[86320:8464807] D restkit.object_mapping:RKMapperOperation.m:258 Asked to map source object {
    checksum = xxx;
    contentToken = "xxx-duHZ0DyOA-g~";
    name = "2015-09-18 104307-3859795.JPG";
    parentPath = "/xxx";
    size = 3859795;
    systemAttributes =     {
        "Capture-Date" = "2015-09-18T14:43:07.000Z";
        "Geo-Latitude" = "40.00000";
        "Geo-Longitude" = "-74.00000";
        Height = 3024;
        "Mime-Type" = "image/jpeg";
        Orientation = 6;
        "Timeline-Date" = "2015-09-18T14:43:07.000Z";
        Width = 4032;
    };
    version = 1;
    versionCreated = "2015-09-18T14:53:19.610Z";
} with mapping <RKObjectMapping:0x7fa958654190 objectClass=CloudFileModel propertyMappings=(
    "<RKAttributeMapping: 0x7fa958729b60 parentPath => parentPath>",
    "<RKAttributeMapping: 0x7fa958654500 name => name>"
)>...
2016-01-18 09:50:33.803 CloudAPIRestKit[86320:8464807] D restkit.object_mapping:RKMappingOperation.m:1172 Starting mapping operation...

2016-01-18 09:50:33.901 CloudAPIRestKit[86320:8464807] D restkit.object_mapping:RKMappingOperation.m:1172 Starting mapping operation...
2016-01-18 09:50:33.902 CloudAPIRestKit[86320:8464807] T restkit.object_mapping:RKMappingOperation.m:1173 Performing mapping operation: <RKMappingOperation 0x7fa95ab51040> for 'CloudFileModel' object. Mapping values from object {
    checksum = xxx;
    contentToken = "xxx~";
    name = "2015-06-26 133729-1708809.JPG";
    parentPath = "/xxx";
    size = 1708809;
    systemAttributes =     {
        "Capture-Date" = "2015-06-26T17:37:29.000Z";
        "Geo-Latitude" = "40.00000";
        "Geo-Longitude" = "-74.00000";
        Height = 2448;
        "Mime-Type" = "image/jpeg";
        Orientation = 6;
        "Timeline-Date" = "2015-06-26T17:37:29.000Z";
        Width = 3264;
    };
    version = 4;
    versionCreated = "2015-09-16T19:51:37.749Z";
} to object <CloudFileModel: 0x7fa95aa212b0> with object mapping (null)
CloudAPIRestKit[86320:8464807]D restkit.object_mapping:rkmapperooperation.m:414为表示执行映射操作:{
数据={
文件=(
{
校验和=xxx;
contentToken=“xxx-gmkQ4oOO1c~”;
name=“2015-09-18 104310-4377094.JPG”;
parentPath=“/xxx”;
尺寸=4377094;
贡品={
“捕获日期”=“2015-09-18T14:43:10.000Z”;
“地理纬度”=“40.00000”;
“地理经度”=“-74.00000”;
高度=3024;
“Mime类型”=“图像/jpeg”;
方向=6;
“时间线日期”=“2015-09-18T14:43:10.000Z”;
宽度=4032;
};
版本=1;
versionCreated=“2015-09-18T14:53:36.525Z”;
},...
}带映射
2016-01-18 09:50:31.262 CloudAPIRestKit[86320:8464807]D restkit对象映射:RKMappingOperation.m:1172开始映射操作。。。
2016-01-18 09:50:31.263 CloudAPIRestKit[86320:8464807]T restkit.对象映射:RKMappingOperation.m:1173执行映射操作:针对“CloudFileModel”对象。映射来自对象的值{
校验和=xxx;
contentToken=“xxx xxx~”;
name=“2015-09-18 104310-4377094.JPG”;
parentPath=“/xxx”;
尺寸=4377094;
贡品={
“捕获日期”=“2015-09-18T14:43:10.000Z”;
“地理纬度”=“40.00000”;
“地理经度”=“-74.00000”;
高度=3024;
“Mime类型”=“图像/jpeg”;
方向=6;
“时间线日期”=“2015-09-18T14:43:10.000Z”;
宽度=4032;
};
版本=1;
versionCreated=“2015-09-18T14:53:36.525Z”;
}到具有对象映射的对象(空)
2016-01-18 09:50:31.264 CloudAPIRestKit[86320:8464807]T restkit.对象映射:RKMappingOperation.m:693在键路径“parentPath”处找到了可转换的值。正在从类“\u NSCFString”转换为“NSString”
2016-01-18 09:50:31.265 CloudAPIRestKit[86320:8464807]T restkit.对象映射:RKMappingOperation.m:712将属性值keyPath“parentPath”映射到“parentPath”
2016-01-18 09:50:31.265 CloudAPIRestKit[86320:8464807]T restkit.object_mapping:RKMappingOperation.m:728将属性值从keyPath“parentPath”映射到“parentPath”。值:/VZMOBILE/Cellco Test的iPhone
2016-01-18 09:50:31.266 CloudAPIRestKit[86320:8464807]T restkit.对象映射:RKMappingOperation.m:693在键路径“name”处找到了可转换的值。正在从类“NSCFString”转换为“NSString”
2016-01-18 09:50:31.266 CloudAPIRestKit[86320:8464807]T restkit.对象映射:RKMappingOperation.m:712将属性值keyPath“name”映射到“name”
2016-01-18 09:50:31.267 CloudAPIRestKit[86320:8464807]T restkit.对象映射:RKMappingOperation.m:728将属性值从keyPath“name”映射到“name”。值:2015-09-18 104310-4377094.JPG
2016-01-18 09:50:31.267 CloudAPIRestKit[86320:8464807]D restkit.对象映射:RKMappingOperation.m:1273成功完成映射操作。。。
2016-01-18 09:50:31.268 CloudAPIRestKit[86320:8464807]D restkit.对象映射:RKMapperOperation.m:258请求映射源对象{
校验和=xxx;
contentToken=“xxx-duHZ0DyOA-g~”;
name=“2015-09-18 104307-3859795.JPG”;
parentPath=“/xxx”;
尺寸=3859795;
贡品={
“捕获日期”=“2015-09-18T14:43:07.000Z”;
“地理纬度”=“40.00000”;
“地理经度”=“-74.00000”;
高度=3024;
“Mime类型”=“图像/jpeg”;
方向=6;
“时间线日期”=“2015-09-18T14:43:07.000Z”;
宽度=4032;
};
版本=1;
versionCreated=“2015-09-18T14:53:19.610Z”;
}使用映射。。。
2016-01-18 09:50:33.803 CloudAPIRestKit[86320:8464807]D restkit.对象映射:RKMappingOperation.m:1172正在启动映射操作。。。
2016-01-18 09:50:33.901 CloudAPIRestKit[86320:8464807]D restkit.对象映射:RKMappingOperation.m:1172正在启动映射操作。。。
2016-01-18 09:50:33.902 CloudAPIRestKit[86320:8464807]T restkit.对象映射:RKMappingOperation.m:1173执行映射操作:针对“CloudFileModel”对象。映射来自对象的值{
校验和=xxx;
contentToken=“xxx~”;
name=“2015-06-26 133729-1708809.JPG”;
parentPath=“/xxx”;
尺寸=1708809;
贡品={
“捕获日期”=“2015-06-26T17:37:29.000Z”;
“地理纬度”=“40.00000”;
“地理经度”=“-74.00000”;
高度=2448;
“Mime类型”=“图像/jpeg”;
方向=6;
“时间线日期”=“2015-06-26T17:37:29.000Z”;
宽度=3264;
};
版本=4;
versionCreated=“2015-09-16T19:51:37.749Z”;
}到具有对象映射的对象(空)
这是调试器在[[RKObjectRequestOperation responseMappingQueue]addOperation:self.responseMapperOperation]之前显示的内容


可能您尚未将描述符添加到对象管理器:

[objectManager addResponseDescriptor:responseDescriptor];

显示JSON。映射中只有一个键?@Wain我拥有映射中的所有键,但为了简化问题,我将其缩减为一个。在问题中添加了一个JSON片段。我在该JSON中没有看到任何数据键,在RestKitupdated JSON片段中打开跟踪日志没有明显错误,需要跟踪日志