RestKit警告:"找到一个只包含NSNull值的集合......"

Jan*_*dek 6 objective-c restkit

我有一个基于RestKit的应用程序与一个映射类.一切似乎都很好.但是,当我检索对象时,RestKit会发出警告:

W restkit.object_mapping:RKObjectMapper.m:90 Found a collection containing only NSNull values, considering the collection unmappable...
Run Code Online (Sandbox Code Playgroud)

警告出现两次(可能是因为JSON响应中有两个对象).我该如何解决这个问题?

这是我的映射:

RKManagedObjectMapping* presentationMapping = [RKManagedObjectMapping mappingForClass:[Presentation class]];
presentationMapping.primaryKeyAttribute = @"presentationId";
[presentationMapping mapKeyPath:@"id" toAttribute:@"presentationId"];
[presentationMapping mapKeyPath:@"title" toAttribute:@"title"];
[presentationMapping mapKeyPath:@"description" toAttribute:@"descriptionText"];
[presentationMapping mapKeyPath:@"download_url" toAttribute:@"downloadUrlString"];
[presentationMapping mapKeyPath:@"download_file_size" toAttribute:@"downloadFileSize"];

[objectManager.mappingProvider setMapping:presentationMapping forKeyPath:@"presentation"];
Run Code Online (Sandbox Code Playgroud)

这是我检索对象的方法:

[[RKObjectManager sharedManager] loadObjectsAtResourcePath:@"/presentations" delegate:self];
Run Code Online (Sandbox Code Playgroud)

这是我的JSON结构(通过curl检索):

[
  {
    "presentation": {
      "created_at":"2011-08-13T17:09:40+02:00",
      "description":"Lorem ipsum",
      "id":1,
      "title":"Xxx",
      "updated_at":"2011-08-13T17:09:40+02:00",
      "download_url":"http://xxx.example.com/system/downloads/1/original/presentation1.zip?1313248180",
      "download_file_size":171703
    }
  },
  {
    "presentation": {
      "created_at":"2011-08-13T17:10:30+02:00",
      "description":"Dolor sit amet",
      "id":2,
      "title":"Zzz",
      "updated_at":"2011-08-15T00:22:10+02:00",
      "download_url":"http://xxx.example.com/system/downloads/2/original/zzz.zip?1313360530",
      "download_file_size":3182117
    }
  }
]
Run Code Online (Sandbox Code Playgroud)

服务器是我控制的Rails 3.0应用程序,如果需要可以修改响应格式.

我正在使用RestKit 0.9.3.

小智 1

此警告并不表示映射不正确。事实上,此消息可能应该记录为“调试”或“跟踪”,因为它可能作为正常对象映射的一部分出现。我将提交拉取请求以更改将来的日志级别。因此,请放心,您的映射没有问题,无需进行任何更改即可消除此警告。:)