有时会出现不响应的时候,解决方法就是为这个线程开启一个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]];
}