Download a PDF using AFNetworking 2.0

I want to upgrade to the latest version of AFNetworking. I was wondering how to download a PDF file from the server in order to display it in my application.

In the old version, I used this code:

AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; operation.responseSerializer = [AFHTTPResponseSerializer serializer]; [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { [webView loadData:responseObject MIMEType:@"application/pdf" textEncodingName:nil baseURL:nil]; } failure:^(AFHTTPRequestOperation *operation, NSError *error) { //error handling } [operation start]; 

What does the code look like in AFNetworking 2.0 to do the same job? Should I use a different AFNetworking class?

+6
source share
1 answer

Just need to add

 operation.responseSerializer = [AFHTTPResponseSerializer serializer]; 

Now it is still working. Thanks.

+8
source

Source: https://habr.com/ru/post/957261/


All Articles