1

JSON 応答を取得するには? PHP が JSON 全体のリクエストを出力する場合は失敗し、PHP が何も出力しない場合はレスポンスが成功します。AFHTTPRequestOperation の操作方法

 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);
              }];
4

1 に答える 1