IOS中处理异步连接中的超时
来源:互联网 发布:阿里云服务器租用费用 编辑:程序博客网 时间:2024/05/29 09:22
当时我们创建一个异步的请求的时候,你想设置一个响应超时的值,来完善你的应用程序。设置一下传递给 NSURLConnection 类的参数 URL 请求超时属性。当初始化 NSURLRequest 这个对象,并且把这个对象传递给 URL 连接对象的时候,你可以使用requestWithURL:cachePolicy:timeoutInterval:这个类方法,将超时的值传递给 timeoutInterval 参数。
NSString *urlAsString = @"http://www.apple.com";
NSURL *url = [NSURL URLWithString:urlAsString];
NSURLRequest *urlRequest =
[NSURLRequest
requestWithURL:url cachePolicy:NSURLRequestReloadIgnori
NSOperationQueue *queue = [[NSOperationQueue alloc] init];
[NSURLConnection
sendAsynchronousRequest:urlRequest queue:queue completionHandler:^(NSURLResponse *response, NSData *data,
NSError *error) {
if ([data length] >0 &&
error == nil){
NSString *html = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSLog(@"HTML = %@", html);
}
else if ([data length] == 0 &&
error == nil)
{
NSLog(@"Nothing was downloaded.");
}
else if (error != nil)
{
NSLog(@"Error happened = %@", error);
}
}];
- IOS中处理异步连接中的超时
- 处理异步调用超时
- java中处理http连接超时
- java中处理http连接超时
- TCP连接超时处理
- tcp连接超时处理
- java中处理http连接超时的方法
- java中处理http连接超时的方法
- Angular1中的超时处理
- 网络连接 以及超时处理
- socket connec连接超时处理
- Win7x64PL_SQL_连接Oracle11g超时处理
- Netty连接超时处理方法
- socket connec连接超时处理
- socket 连接超时处理 java
- 关于Extjs异步session超时问题处理
- ajax异步通讯 Session超时的处理
- ajax异步请求,session超时处理
- mathquill 未解决的弊端
- Supported Values for @SuppressWarnings
- UNIX_shell_programming(几道练习题目)
- php array的用法
- jqGrid——合计、默认查询条件、自适应、序号等
- IOS中处理异步连接中的超时
- windows任务定时重启tomcat
- ios排序
- 前端开发必备!Emmet使用手册
- B. Playing Cubes
- 通用的用户登录过滤器(SessionFilter)
- Oracle 货币符号
- cocos2d 'root' is no longer supported问题解决办法
- javascript禁用键盘功能键让右击及其他键无效