我正在尝试使用RestKit解析github的gist api响应。这是json的片段:
{
"url": "https://api.github.com/gists/6004248",
...
"html_url": "https://gist.github.com/6004248",
"files": {
"ApplicationContext.h": {
"filename": "ApplicationContext.h",
"type": "text/plain",
"language": "Objective-C",
"raw_url": "https://gist.github.com/raw/6004248/4531c7534585b273c55ca71ce9020418b7ed271b/ApplicationContext.h",
"size": 481
},
"ApplicationContext.m": {
"filename": "ApplicationContext.m",
"type": "text/plain",
"language": "Objective-C",
"raw_url": "https://gist.github.com/raw/6004248/27a3881f9c5adde700b75199076a5ce259d0b568/ApplicationContext.m",
"size": 542
}
},
...
"user": {
...
},
"comments_url": "https://api.github.com/gists/6004248/comments"
},
一切正常,但我的文件关系有问题。以下是负责文件的代码片段:
RKObjectMapping *gistMapping = [RKObjectMapping mappingForClass:[MBGist class]];
[gistMapping addAttributeMappingsFromDictionary: @{@"url": @"url", @"html_url": @"htmlUrl", @"description": @"description"}];
RKObjectMapping *fileMapping = [RKObjectMapping mappingForClass:[MBFile class]];
[fileMapping addAttributeMappingsFromDictionary:@{@"filename": @"filename", @"language": @"language", @"type":@"type"}];
[gistMapping addPropertyMapping:[RKRelationshipMapping relationshipMappingFromKeyPath:@"files" toKeyPath:@"files" withMapping:fileMapping]];
但我的MBGist类对象中有空文件数组。
有人可以帮我吗?
最诚挚的问候, 米哈尔