
下面是内存溢出 jb51.cc 通过网络收集整理的代码片段。
内存溢出小编现在分享给大家,也给大家做个参考。
1.请求Json数据,使用AFhttpRequestoperation完成 Nsstring *str=[Nsstring stringWithFormat:@"http://int.dpool.sina.com.cn/iplookup/iplookup.PHP?format=Json&ip=218.4.255.255"]; NSURL *url = [NSURL URLWithString:[str stringByAddingPercentEscapesUsingEnCoding:NSUTF8StringEnCoding]]; // UTF-8 NSURLRequest *request = [NSURLRequest requestWithURL:url]; AFhttpRequestoperation *operation = [[AFhttpRequestoperation alloc]initWithRequest:request]; // 请求数据,设置成功与失败的回调函数 [operation setCompletionBlockWithSuccess:^(AFhttpRequestoperation *operation,ID responSEObject) { Nsstring *HTML = operation.responseString; NSData* data=[HTML dataUsingEnCoding:NSUTF8StringEnCoding]; ID dict=[NSJsONSerialization JsONObjectWithData:data options:0 error:nil]; NSLog(@"获取到的数据为:%@",dict); }failure:^(AFhttpRequestoperation *operation,NSError *error) { NSLog(@"发生错误!%@",error); }]; // 加入队列 NSOperationQueue *queue = [[NSOperationQueue alloc] init]; [queue addOperation:operation]; 以上是内存溢出(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
总结以上是内存溢出为你收集整理的iOS AFNetWorking 请求json数据全部内容,希望文章能够帮你解决iOS AFNetWorking 请求json数据所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)