【问题标题】:AFNetworking 3.0 migrationAFNetworking 3.0 迁移
【发布时间】:2016-01-28 08:14:23
【问题描述】:

现在我正在使用AFNetworking 2.0,我想将其迁移到AFNetworking 3.0。我已将文件添加到项目中,它显示了许多错误。我检查了migration guide。我的疑问是如何将NSURLCredential 设置为AFNetworking 3.0.4 中的登录请求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。请帮帮我。

【问题讨论】:

    标签: ios migration afnetworking nsurlcredential afnetworking-3


    【解决方案1】:

    您必须将 AFHTTPRequestOperation 替换为 AFHTTPSessionManager

    然后 AFNetworking 3.0 公开了来自 NSURLSession 的所有身份验证回调,您可以通过 AFURLRequestSerialization 设置您想要的任何标头。

    【讨论】:

      猜你喜欢
      • 2016-06-28
      • 1970-01-01
      • 2017-10-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-02-25
      • 2014-04-17
      • 2014-01-14
      相关资源
      最近更新 更多