Access Response Data in Success callback

后端 未结 2 1228
伪装坚强ぢ
伪装坚强ぢ 2021-01-04 08:35

Is there any way to access the response data in the success block for a request using the object manager?

[objectManager postObject:[User class] path:@\"/use         


        
相关标签:
2条回答
  • 2021-01-04 09:35

    You can get this info from the RKObjectRequestOperation *operation

    operation.HTTPRequestOperation.response
    operation.HTTPRequestOperation.responseData
    operation.HTTPRequestOperation.responseString
    
    0 讨论(0)
  • 2021-01-04 09:35

    try this

    [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);
        }];
    
    0 讨论(0)
提交回复
热议问题