user979331
user979331

Reputation: 11861

AFNetworking calling clearAuthorizationHeader

I see this method in AFNetworking:

- (void)clearAuthorizationHeader {
    [self.mutableHTTPRequestHeaders removeObjectForKey:@"Authorization"];
}

how would I call this method in another file? I tried the following:

#import "AFURLRequestSerialization.h"
AFHTTPRequestSerializer *clear;

and then calling it inside my logout method like so:

[clear.clearAuthorizationHeader];

but I get this error:

/Users/jsuske/Documents/SSiPad(Device Only)ios7/SchedulingiPadApplication/ViewControllers/LHLoginController.m:495:36: Expected identifier

Upvotes: 1

Views: 245

Answers (1)

itinance
itinance

Reputation: 12388

To call a method, you need the space notation instead of a Dot. But you need also a valid object instance of the serializer, which you can get from the AFHTTPRequestOperationManager.

Here is an example code:

AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
AFHTTPRequestSerializer <AFURLRequestSerialization> * requestSerializer = manager.requestSerializer;
[requestSerializer clearAuthorizationHeader];

Upvotes: 3

Related Questions