我是 AFNetworking 的新手,我知道如何传递 URL 参数。但是我如何将标题传递到同一个调用中。
我也在继承我的 AFHTTPSessionManager
请参阅下面的代码:
- (void)getExpenses:(NSString *)page
success:(void (^) (NSArray *myExpenses))success
failure:(RequestFailureBlock)failure
{
NSString *resourceURL = [NSString stringWithFormat:@"%@/expenses/", APIBaseURLString];
NSDictionary *parameters = @{@"page":page, @"Authorization": APIAuthorization};
[self getExpenses:resourceURL parameters:parameters success:success failure:failure];
}
最佳答案
setAuthorizationHeaderFieldWithToken is deprecated 由于 servers having different requirements about how the access token 被发送( token 、承载等)
迈克尔斯回答否则是正确的,请使用[self.requestSerializer setValue:@"Some-Value" forHTTPHeaderField:@"Header-Field"];
或者[self.requestSerializer setAuthorizationHeaderFieldWithUsername:@"" password:@""];
对于基本身份验证
关于ios - AFNetworking 2.0 : Passing header information,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/23134856/