6

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.

Jan Dudek
  • 807
  • 1
  • 9
  • 17

2 Answers2

1

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. :)

Jonathan Grynspan
  • 43,286
  • 8
  • 74
  • 104
jeffarena
  • 501
  • 2
  • 8
0

Still getting this warning on the recently installed RestKit, made the following change in the RestKit code.

FILE: RKPbjectMapper.m 
FUNCTION: (BOOL)isNullCollection:(id)object
LINE: 104

changed:

RKLogWarning(@"Found a collection containing only NSNull values, considering the collection unmappable...");

to:

RKLogDebug(@"Found a collection containing only NSNull values, considering the collection unmappable...");
Jason Plank
  • 2,336
  • 5
  • 31
  • 40
dyst-mingus
  • 269
  • 2
  • 3