Asynchronously with NSURLConnection
NSString *urlAsString=@"http://www.apple.com";
NSURL *url=[NSURL URLWithString:urlAsString];
NSURLRequest *urlRequest=[NSURLRequest requestWithURL:url];
NSOperationQueue *queue=[[NSOperationQueue alloc]init]; [NSURLConnection sendAsynchronousRequest:urlRequest queue:queue completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {
if ([data length]> && error==nil) {
NSString *html=[[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding];
NSLog(@"Html is %@",html);
}else if([data length]== && error ==nil){
NSLog(@"Nothing was downloaded!");
}else if(error !=nil){
NSLog(@"Error happeded! %@",error);
}
}];
Asynchronously with NSURLConnection的更多相关文章
- How to make an HTTP request in Swift
from: http://stackoverflow.com/questions/24016142/how-to-make-an-http-request-in-swift You can use N ...
- iOS 网络编程:NSURLConnection
1 简介 1.1 概念 NSURLConnection类似NSURLSession,都是进行网络数据传输的.其中NSURLSession是NSURLConnection的替代版本,目前IOS9.0几乎 ...
- NSURLConnection实现文件上传和AFNetworking实现文件上传
请求的步骤分为4步 1.创建请求 2.设置请求头(告诉服务器这是一个文件上传的请求) 3.设置请求体 4.发送请求 NSURLConnection实现文件上传 // 1.创建请求 NSURL *url ...
- iOS网络1——NSURLConnection使用详解
原文在此 一.整体介绍 NSURLConnection是苹果提供的原生网络访问类,但是苹果很快会将其废弃,且由NSURLSession(iOS7以后)来替代.目前使用最广泛的第三方网络框架AFNetw ...
- NSURLConnection学习笔记
虽说现在都用三方库来获取网络数据,再不济也会用苹果官方的NSURLSession,但有些东西还是要先学会才有资格说不好不用,不是么? NSURLConnection发送请求是分为同步和异步两种方式的, ...
- 网络第一节——NSURLConnection
一.NSURLConnection的常用类 (1)NSURL:请求地址 (2)NSURLRequest:封装一个请求,保存发给服务器的全部数据,包括一个NSURL对象,请求方法.请求头.请求体.... ...
- NSURLConnection的使用
一:NSURLConnection(IOS9.0已经弃用)是早期apple提供的http访问方式.以下列出了常用的几个场景:GET请求,POST请求,Response中带有json数据 对于NSURL ...
- post NSURLConnection请求网络数据
#import "ViewController.h" @interface ViewController () @end @implementation ViewControlle ...
- NSURLConnection 异步加载网络数据
#import "ViewController.h" @interface ViewController () @end @implementation ViewControlle ...
随机推荐
- 自定义popupmenu菜单背景色
procedure TForm1.N11DrawItem(Sender: TObject; ACanvas: TCanvas; ARect: TRect; Selected: Boolean); be ...
- FusionChart 导出图片 功能实现(转载)
FusionChart 导出图片 功能实现(转载) http://www.cnblogs.com/jiagoushi/archive/2013/02/05/2893468.html 题目:精美Fusi ...
- ### core文件使用
在Linux下程序崩溃,特别是在循环中产生Segment Fault错误时,根本不知道程序在哪出错,这时,利用core文件可以快速找到出错的问题所在. #@author: gr #@date: 201 ...
- 导出Execel
//请求入口 @SuppressWarnings("serial")@ParentPackage("default") //action请求@Results( ...
- linux中 ECShop的文件不能写
解决办法: 1.开放权限 使用命令:chmod -R 777 文件路径 2.关闭SELinux 使用命令:setenforce 0
- Yii 关于 find findAll 查找出制定的字段的方法
总所周知 modelName::model() -> find() //找出的是一个对象 modelName::model() -> findALL() //找出的是一个对象集合的数组 如 ...
- lsof作用
lsof 卸载移动存储时经常提示device busy,也可能误删了一个正在打开的文件.... 这时候可以试试lsof lsof简介 lsof(list open files)是一个列出当前系统打 ...
- H5 APP开发必读,20个你不知道的Html5新特征和窍门
Jeffrey Way曾发表过一篇博文<28 HTML5 Features, Tips, and Techniques you Must Know >讲述了28个HTML5特征.窍门和技术 ...
- 构造SEH来实现跳转-转载
下面的代码出自CSDN Delphi版的一高人(kiboisme 蓝色光芒) procedure ExceptProc{ExceptionRecord,SEH,Context,DispatcherCo ...
- poj 2104 K-th Number 划分树,主席树讲解
K-th Number Input The first line of the input file contains n --- the size of the array, and m --- t ...