Afnetworking 1.0 builds on Nsurlconnection's underlying API, Afnetworking 2.0 starts using Nsurlconnection's underlying API, and options for newer Nsurlsession-based APIs. Afnetworking 3.0 is now fully based on the Nsurlsession API, which reduces the burden of maintenance while supporting Apple to enhance any additional functionality offered by Nsurlsession. Because of Xcode 7, Nsurlconnection's API has officially been deprecated by Apple. While the API will continue to run, there will be no new features to be added, and Apple has notified all network-based features to fully enable nsurlsession to evolve.
Deprecated classes:The following class has been deprecated from Afnetworking 3.0: Afurlconnectionoperationafhttprequestoperationafhttprequestoperationmanager
Modified class:The following class contains an internal implementation of the Nsurlconnection-based API. They've been used nsurlsession refactoring: uiimageview+afnetworkinguiwebview+afnetworkinguibutton+afnetworking
Afhttprequestoperationmanager Core Code
If you have used Afhttprequestoperationmanager before, you will need to migrate to use Afhttpsessionmanager. The following classes do not change between the two transitions: securitypolicyrequestserializerresponseserializer
Afnetworking 2.x
| 123456 |
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];[manager GET:@"请求的url"parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) { NSLog(@"成功");} failure:^(AFHTTPRequestOperation *operation, NSError*error) { NSLog(@"失败");}]; |
Afnetworking 3.0
| 123456 |
AFHTTPSessionManager *session = [AFHTTPSessionManager manager];[session GET:@"请求的url"parameters:nil success:^(NSURLSessionDataTask *task, id responseObject) { NSLog(@"成功");} failure:^(NSURLSessionDataTask *task, NSError *error) { NSLog(@"失败"); }]; |
AFN2.0 to 3.0 Migration