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


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

链接地址: http://www.djcxy.com/p/75716.html

上一篇: iPhone地址栏阻止HTML页眉按钮?

下一篇: 如何设置AFNetworking 2.0默认标题?