2011-08-15 36 views
6

Tôi có một ứng dụng dựa trên RestKit với một lớp được ánh xạ. Mọi thứ dường như hoạt động tốt. Tuy nhiên, khi tôi truy xuất các đối tượng, RestKit phát ra cảnh báo:Cảnh báo RestKit: "Tìm thấy một bộ sưu tập chỉ chứa giá trị NSNull ..."

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

Cảnh báo xuất hiện hai lần (có lẽ vì có hai đối tượng trong phản hồi JSON). Lam sao tôi co thể sửa no?

Dưới đây là bản đồ của tôi:

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

Đây là cách tôi lấy đối tượng:

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

Dưới đây là cấu trúc JSON của tôi (lấy thông qua 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 
    } 
    } 
] 

Máy chủ là Rails 3.0 ứng dụng mà tôi kiểm soát và có thể sửa đổi định dạng phản hồi nếu cần.

Tôi đang sử dụng RestKit 0.9.3.

Trả lời

1

Cảnh báo này không phải là dấu hiệu của ánh xạ không đúng. Trong thực tế, thông báo này có lẽ nên được ghi lại dưới dạng Debug hoặc Trace vì nó có thể xảy ra như là một phần của ánh xạ đối tượng bình thường. Tôi sẽ gửi yêu cầu kéo để thay đổi cấp độ nhật ký cho tương lai. Vì vậy, yên tâm lập bản đồ của bạn là tốt và không có thay đổi là cần thiết để làm yên lặng cảnh báo này. :)

+0

Cảm ơn phản hồi của bạn :) –

0

Vẫn nhận được cảnh báo này trên RestKit được cài đặt gần đây, thực hiện thay đổi sau trong mã RestKit.

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

thay đổi:

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

tới:

RKLogDebug(@"Found a collection containing only NSNull values, considering the collection unmappable..."); 
Các vấn đề liên quan