2013-10-30 5 views
1

JSON 응답을받는 방법은 무엇입니까? PHP에서 일부 JSON 전체 요청을 인쇄하지 못했습니다. PHP가 아무 것도 인쇄하지 않으면 응답이 성공합니다. AFHTTPRequestOperation을 사용하는 방법? 성공 블록 시도에서AFHTTPRequestOperationManager 서버에서 응답받는 방법

AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; 
     NSDictionary *parameters = @{@"foo":@"barr"}; 
     UIImage *image = myImage.image; 
     [manager POST:@"http://local/index.php" 
      parameters:parameters 
    constructingBodyWithBlock:^(id<AFMultipartFormData> formData){ 
     [formData appendPartWithFileData:UIImageJPEGRepresentation(image, 0.7) 
            name:@"file" 
           fileName:@"photo.jpg" 
           mimeType:@"image/jpeg"]; 
    } 
       success:^(AFHTTPRequestOperation *operation, id responseObject){ 
        NSLog(@"Success: %@", responseObject); 
       } 
       failure:^(AFHTTPRequestOperation *operation, NSError *error){ 
        NSLog(@"Error %@", operation.responseString); 
       }]; 

답변

0

:

NSError *e; 
NSDictionary *jsonDict = [NSJSONSerialization JSONObjectWithData:[operation.responseString dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingMutableContainers error:&e]; 
관련 문제