Afnetworking 2.5. Use of version 0

Source: Internet
Author: User

Afnetworking 2.5. Use of version 0

http://afnetworking.com/

http://cocoadocs.org/docsets/AFNetworking/2.5.0/

1. Download the source code and compile it

Source Address Http://pan.baidu.com/s/1jG24w3W

2. Determine if there is a current network, the base URL is http://baidu.com/

Source:

can be used to monitor Wwan or WiFi or off-screen status;)

    //Benchmark BaseURLNsurl *baseurl = [Nsurl urlwithstring:@"http://baidu.com/"]; Afhttprequestoperationmanager*manager =[[Afhttprequestoperationmanager alloc] initwithbaseurl:baseurl]; Nsoperationqueue*operationqueue =Manager.operationqueue; [Manager.reachabilitymanager Setreachabilitystatuschangeblock:^(afnetworkreachabilitystatus status) {Switch(status) { CaseAfnetworkreachabilitystatusreachableviawwan: CaseAfnetworkreachabilitystatusreachableviawifi: [Operationqueue Setsuspended:no]; //network notifications can be sent hereNSLog (@"have network");  Break;  Caseafnetworkreachabilitystatusnotreachable:default: [Operationqueue Setsuspended:yes]; //you can send off-screen notifications hereNSLog (@"It's off the grid.");  Break;        }    }]; //Start monitoring network[Manager.reachabilitymanager startmonitoring];

3. Get request with no parameters

Source:

    //Initialize URLsNSString *requestaddress =         @"http://api.openweathermap.org/data/2.5/forecast/daily?lat=39.88293652833437&lon=116.4621119300779& LANG=ZH_CN"; Afhttprequestoperationmanager*manager =[Afhttprequestoperationmanager Manager]; //GET request with no parameters[Manager get:requestaddress Parameters:nil success:^ (Afhttprequestoperation *operation,IDresponseobject) {NSLog (@"%@", Responseobject); } Failure:^ (Afhttprequestoperation *operation, Nserror *error) {NSLog (@"%@", error); }];

Afnetworking 2.5. Use of version 0

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.