我正在为我的项目使用 Restkit 0.20。我提出这样的要求。
NSData *postData = [params dataUsingEncoding:NSUTF8StringEncoding];
NSURL *url = [NSURL URLWithString:baseUrl];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:path relativeToURL:url]];
[request setHTTPMethod:@"POST"];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:postData];
RKObjectManager *manager = [[RestKit sharedDataManager] objectManager];
RKManagedObjectRequestOperation *operation = [manager managedObjectRequestOperationWithRequest:request managedObjectContext:manager.managedObjectStore.persistentStoreManagedObjectContext success:^(RKObjectRequestOperation *operation1, RKMappingResult *mappingResult) {
block ([mappingResult array]);
} failure:^(RKObjectRequestOperation *operation1, NSError *error) {
RKLogDebug(@"Failure %@",error.debugDescription);
block (error);
}];
在竞争映射操作之后,我使用块返回一个数组。我需要在委托中获得响应以用于某些操作。是否有任何类似于 Restkit0.10 中的 didReceiveResponse 的方法,而且我知道这个线程https://groups.google.com/forum/#!topic/restkit/TrWH5GR-gFU布莱克提到我们可以完全控制通过 NSURLRequest 对象的标头。但是当我使用 RKManagedObjectRequestOperation 时如何使用 NSURLRequest。任何人都可以发布一些例子。
谢谢