3

I'm Currently working on a project where I'm using AFNetworking 2.0 library to GET and POST the data to and from server.In some cases i wanted to pass a token value as header type for the request with AFHTTPRequestOperationManager. So far this is what i found

[manager.requestSerializer setAuthorizationHeaderFieldWithToken:TOKEN_VALUE];

but it is deprecated in version 2.0, and i also learned in version AFNetWorking 2.2.1 it is not deprecated. But i couldn't find the library with version 2.2.1 to download it. Please help me out if there is any other way that i can set token as my header for AFHTTPRequestOperationManager. And also any link to download the AFNetworking latest version library.

Madhu
  • 869
  • 1
  • 17
  • 37

1 Answers1

3

This is the deprecation message in the AFNetworking docs:

This method has been deprecated. Use setValue:forHTTPHeaderField: instead. (Deprecated: This method has been deprecated. Use -setValue:forHTTPHeaderField: instead.)

The docs for this method setValue:forHTTPHeaderField: can be found here. To set a token as your header with the AFNetworking method setValue:forHTTPHeaderField: try:

AFHTTPRequestOperationManager *manager = [[AFHTTPRequestOperationManager manager] initWithBaseURL:@"http://someurl.com"];

[manager.requestSerializer setValue:@"Token token=token_name" forHTTPHeaderField:@"Authorization"];
Jonathan Yeong
  • 523
  • 1
  • 4
  • 8
  • whenever i use [setValue: forHTTPHeaderField: ] method i can't send any value for @"Authorization" field. But could successfully send value for the @"Content-Type" field. Can anyone help me out of this? – EarlySun Jun 24 '15 at 05:50