有没有办法使用对象管理器访问成功块中的响应数据?
[objectManager postObject:[User class] path:@"/users" parameters:nil success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) {
NSLog(@"success");
} failure:^(RKObjectRequestOperation *operation, NSError *error) {
NSLog(@"failure");
}];
似乎应该有一些方法可以使用映射或操作来获取此信息,如NSData或其他东西。
答案 0 :(得分:32)
您可以从RKObjectRequestOperation *操作
获取此信息operation.HTTPRequestOperation.response
operation.HTTPRequestOperation.responseData
operation.HTTPRequestOperation.responseString
答案 1 :(得分:6)
试试这个
[objectRequestOperation setCompletionBlockWithSuccess:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) {
// parse the response---
NSDictionary *myDic = [NSJSONSerialization JSONObjectWithData:operation.HTTPRequestOperation.responseData options:NSJSONReadingMutableLeaves error:nil];
NSLog(@"=======:%@",myDic);
NSLog(@"MY email============ %@ ",[myDic objectForKey:@"Email"]);
} failure:^(RKObjectRequestOperation *operation, NSError *error) {
RKLogError(@"Operation failed with error: %@", error);
}];