I want to update to the latest version of AFNetworking. I was wondering how to download a PDF from a server to display it in my app.
On 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 get the same job done? Do I have to use another class of AFNetworking?
Just need to add
operation.responseSerializer = [AFHTTPResponseSerializer serializer];
Now it is working so far. Thanks.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With