Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RestKit warning: "Found a collection containing only NSNull values..."

I have a RestKit-based app with one mapped class. Everything seems to work fine. However, when I retrieve objects, RestKit emits a warning:

W restkit.object_mapping:RKObjectMapper.m:90 Found a collection containing only NSNull values, considering the collection unmappable...

The warning appears twice (presumably because there are two objects in JSON response). How can I fix that?

Here's my mapping:

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"];

Here's how I retrieve objects:

[[RKObjectManager sharedManager] loadObjectsAtResourcePath:@"/presentations" delegate:self];

Here's my JSON structure (retrieved via 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
    }
  }
]

The server is Rails 3.0 app which I control and can modify response format if needed.

I'm using RestKit 0.9.3.

like image 347
Jan Dudek Avatar asked Aug 15 '11 11:08

Jan Dudek


1 Answers

This warning is not a sign of an improper mapping. In fact this message should probably be logged as Debug or Trace as it can occur as part of normal object mapping. I'll submit a pull request to change the log level for the future. So rest assured your mapping is fine and no changes are necessary to quiet this warning. :)

like image 89
jeffarena Avatar answered Oct 16 '22 17:10

jeffarena