我有一個基於RestKit的應用程序,其中包含一個映射類。一切似乎都很好。然而,當我檢索對象,RestKit發出警告:RestKit警告:「發現僅包含NSNull值的集合...」
W restkit.object_mapping:RKObjectMapper.m:90 Found a collection containing only NSNull values, considering the collection unmappable...
出現警告兩次(大概是因爲在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"];
這裏是我如何檢索對象:
[[RKObjectManager sharedManager] loadObjectsAtResourcePath:@"/presentations" delegate:self];
這裏是(通過捲曲檢索)我的JSON結構:
[
{
"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
}
}
]
服務器是Rails的3.0我控制的應用程序,如果需要可以修改響應格式。
我正在使用RestKit 0.9.3。
感謝您的答覆:) –