다행히 AFNNetworking 프레임 워크를 사용하여이 작업을 돕고 RestKit 시리얼 라이저를 사용하여 필요한 요청 개체를 생성했습니다.
MyRequestClass *request = // ... get my request class instance
RKObjectManager *manager = [RKObjectManager sharedManager];
NSMutableURLRequest *downloadRequest = [manager requestWithObject:request method:RKRequestMethodPOST path:ROUTE_URL_MY_SERVICE parameters:nil];
AFHTTPRequestOperation *requestOperation = [[AFImageRequestOperation alloc] initWithRequest:downloadRequest];
[requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
// Use my success callback with the binary data and MIME type string
callback(operation.responseData, operation.response.MIMEType, nil);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
// Error callback
callback(nil, nil, error);
}];
[manager.HTTPClient enqueueHTTPRequestOperation:requestOperation];
나는 최신 restkit를 사용하여 간단한 미리보기 이미지를 다운로드하는 발견 코드, –
:-) 덕분에 최고의 조각 나는 MyResponseClass에 매핑 할 수 있습니다 어떻게 JSON을받은 경우? – giuseppe
바이너리를 받기 위해 JSON을 보내는 것입니다. 응답 객체 (JSON 형식)를 클래스에 매핑하려면 POST 호출 또는 기타를 만들고 Restkit이 매핑을 수행하도록 'RKObjectManager'를 사용해야합니다. restkit 웹 사이트에는이를 수행하는 몇 가지 예가 있습니다 (https://github.com/RestKit/RestKit/). –