NSURLConnection 不响应Delegate方法
2015-09-22 19:01
295 查看
有时会出现不响应的时候,解决方法就是为这个线程开启一个runloop使它始终处于运行状态
//设置请求超时时间为30s NSMutableURLRequest *requestLoad = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"http://box.zhangmen.baidu.com/bdlrc/93/9351.lrc"] cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30.0]; self.connection = [[NSURLConnection alloc] initWithRequest:requestLoad delegate:self]; //开启一个runloop,使它始终处于运行状态 UIApplication *app = [UIApplication sharedApplication]; app.networkActivityIndicatorVisible = YES; finished = NO; while (!finished) { [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]]; }
相关文章推荐
- Android M新控件之FloatingActionButton,TextInputLayout,Snackbar,TabLayout的使用
- 一些算法问题(转载)
- hdu1556
- char,varchar,varchar2,nchar……区别
- 树莓派与超声波测距
- 自动生成Android屏幕适配的dimens.xml
- hdu4418 Time travel(高斯消元法+概率)
- IOS UIView
- Single Number
- python3 入门 (一) 基础语法
- ThinkPHP-给已上传图片生成缩略图并在列表显示
- HDU_3376_Matrix Again(最小费用流)
- Cookie
- android的消息处理机制(图文+源码分析)—Looper/Handler/Message[转]
- bounds的剖析
- Notification的使用(待完善)-〉添加点击取消,显示优化
- 0,22, 47, 120,(? ),290
- 火星信息安全研究院
- ./configure是干什么的?make install又是干什么的?
- hdu1166解题报告