2011-08-15 33 views
6

我有一個基於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。

回答

1

此警告不是映射不正確的標誌。實際上,該消息應該記錄爲Debug或Trace,因爲它可以作爲普通對象映射的一部分發生。我會提交一個pull請求來改變未來的日誌級別。所以放心,你的映射是好的,沒有必要改變這個警告。 :)

+0

感謝您的答覆:) –

0

仍在最近安裝的RestKit上收到此警告,在RestKit代碼中進行了以下更改。

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

改變:

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

到:

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