When I try to connect to soundcloud using below code:
// 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];
While I get below error:
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, NSErrorFailingURLKey=https://soundcloud.com/api, kCFStreamErrorDomainKey=1, kCFStreamErrorCodeKey=50, NSLocalizedDescription=The Internet connection appears to be offline.}
The Key is: I am running it on my iPhone, the network is 4G. The code is actually working well when I am using other network through Wifi.
The reason is the 4G network turned off for the app on my iPhone, not sure when and why I did it though.
i found the solution its because you set timeoutInterval:10.0 in
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"https://soundcloud.com/api"] cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:10.0];
and response didn't get within this time, so all you need to exceed this time or you can also remove this interval
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With