当我尝试使用以下代码连接到
soundcloud时:
// Create the request. NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"https://soundcloud.com/api"] cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:10.0]; // Create url connection and fire request NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest:request delegate:self];
当我得到以下错误:
Error Domain=NSURLErrorDomain Code=-1009 "The Internet connection appears to be offline." UserInfo={NSUnderlyingError=0x14cfccae0 {Error Domain=kcfErrorDomainCFNetwork Code=-1009 "The Internet connection appears to be offline." UserInfo={NSErrorFailingURLStringKey=https://soundcloud.com/api,NSErrorFailingURLKey=https://soundcloud.com/api,kcfStreamErrorCodeKey=50,kcfStreamErrorDomainKey=1,NSLocalizedDescription=The Internet connection appears to be offline.}},NSErrorFailingURLStringKey=https://soundcloud.com/api,NSLocalizedDescription=The Internet connection appears to be offline.}
关键是:我在iPhone上运行它,网络是4G.当我通过Wifi使用其他网络时,代码实际上运行良好.
解决方法
原因是我的iPhone上的应用程序关闭了4G网络,不知道我何时以及为什么这样做.