Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set the AFNetworking 2.0 default header?

The following commands work fine with the AFNetworking 1.x library

[self registerHTTPOperationClass:[AFJSONRequestOperation class]];
...
[self setDefaultHeader:@"Accept" value:@"application/json"];

What's the equivalent of these functions in AFNetworking 2.0 ?

Thanks

like image 789
ielyamani Avatar asked Nov 24 '13 01:11

ielyamani


1 Answers

You can set header values on the instance of AFHTTPRequestSerializer that is assigned to your AFHTTPSessionManager (iOS 7) or AFHTTPRequestOperationManager (iOS 6) instance. AFNetworking will use the header fields in the request serializer when it builds and executes your requests. You can also subclass AFHTTPRequestSerializer to provide default behavior across all instances. See http://cocoadocs.org/docsets/AFNetworking/2.0.0/Classes/AFHTTPRequestSerializer.html

like image 108
timschmitz Avatar answered Nov 09 '22 23:11

timschmitz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!