现在我正在使用AFNetworking 2.0,我想把它移植到AFNetworking 3.0上。我已经在项目中添加了文件,它显示了许多错误。我查过migration guide了。我的疑问是如何在AFNetworking 3.0.4中将NSURLCredential设置为登录请求url。现在我正在使用,
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
if ([url rangeOfString:NSLoginUrl].location != NSNotFound)
{
NSURLCredential *credential = [NSURLCredential credentialWithUser:@"userName" password:@"password" persistence:NSURLCredentialPersistenceNone];
[operation setCredential:credential];
}但是AFNetworking 3不支持AFHTTPRequestOperation和AFHTTPRequestOperationManager。请帮帮我。
发布于 2016-03-15 22:51:24
您必须将AFHTTPRequestOperation替换为AFHTTPSessionManager
然后,AFNetworking 3.0公开了来自NSURLSession的所有身份验证回调,您可以通过AFURLRequestSerialization设置任何头部。
https://stackoverflow.com/questions/35056016
复制相似问题