AFN2.0 to 3.0 Migration

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.