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