2016-01-28 78 views
0

現在我正在使用AFNetworking 2.0,我想將它遷移到AFNetworking 3.0。我已經將文件添加到項目中,它顯示了很多錯誤。我檢查了migration guide。我的疑問是如何將NSURLCredential設置爲AFNetworking 3.0.4中的登錄請求url。我現在用的,AFNetworking 3.0遷移

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不支持AFHTTPRequestOperationAFHTTPRequestOperationManager。請幫幫我。

回答

0

必須更換AFHTTPRequestOperation到AFHTTPSessionManager

然後AFNetworking 3.0暴露所有來自NSURLSession認證回調,您可以設置將通過AFURLRequestSerialization喜歡的標題。