0
是否有可能使用RestKit將請求發佈到期望JSON字典列表的服務器? :用於發佈JSON列表的RestKit映射
[
{ "key1":"value1",
"key2":"value2"
}
]
維基:https://github.com/RestKit/RestKit/wiki/Object-Mapping#mapping-without-kvc講述如何在響應完成 - 從映射JSON對象 - 但不是周圍的其他方式 - 反對JSON。爲了使問題複雜化,我認爲URL請求的格式爲http://www.example.com/some-name/upload - 不是很安靜。
感謝您的任何幫助。
編輯:
由於北斗星強迫我看的更深找到解決辦法 - 我不知道這是可能的。基於由blakewatters記錄RestKit問題398我解決了這樣的問題:
RKObjectMapping *requestMapping = [RKObjectMapping requestMapping];
[requestMapping addAttributeMappingsFromDictionary:@{@"key1":@"value1", @"key2":@"value2"}];
RKRequestDescriptor *requestDescriptor =
[RKRequestDescriptor requestDescriptorWithMapping:requestMapping
objectClass:[MyObjectClass class]
rootKeyPath:nil
method:RKRequestMethodPOST];
[objectManager addRequestDescriptor:requestDescriptor];
[[RKObjectManager sharedManager] postObject:@[self.myObject]
path:@"/path/myobject/upload"
parameters:nil
success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) {
NSLog(@"Success!");
}
failure:^(RKObjectRequestOperation *operation, NSError *error) {
NSLog(@"Fail.");
}];
我認爲關鍵是把myObject的一個數組,然後設置「rootKeyPath」和「參數」爲零。