ios网络开发 AFNetworking
AFNetworking的出现:MAC/iOS设计的一套网络框架.(为了简化网络操作)
二、AFNetworking的使用
AFN进行GET、POST请求:
1 AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; 2 manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"]; 3 [manager GET:@"http://www.weather.com.cn/data/sk/101010100.html" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) { 4 NSLog(@"JSON: %@", responseObject); 5 } failure:^(AFHTTPRequestOperation *operation, NSError *error) { 6 NSLog(@"Error: %@", error); 7 }];
结果为:
2014-11-05 17:08:26.219 TestAFNetWorking[27957:70b] JSON: {
weatherinfo = {
Radar = "JC_RADAR_AZ9010_JB";
SD = "20%";
WD = "\U897f\U5357\U98ce";
WS = "2\U7ea7";
WSE = 2;
city = "\U5317\U4eac";
cityid = 101010100;
isRadar = 1;
njd = "\U6682\U65e0\U5b9e\U51b5";
qy = 1014;
temp = 17;
time = "16:45";
};
}
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。