In a program I am creating for iOS 5, I am experiencing unexpected behavior with the checkResourceIsReachableAndReturnError method of NSURL.
I created a new project to verify the issue and included only the code:
NSURL *url = [NSURL URLWithString:@"http://www.stackoverflow.com"];
NSError *err = nil;
if([url checkResourceIsReachableAndReturnError:&err]){
NSLog(@"URL is reachable");
}else {
NSLog(@"URL is not reachable");
}
Further, I tried:
NSURL *url = [NSURL URLWithString:@"http://www.stackoverflow.com"];
NSError *err = nil;
[url checkResourceIsReachableAndReturnError:&err];
if(err == nil){
NSLog(@"URL is reachable");
}else {
NSLog(@"URL is not reachable");
}
...still to no avail. The result is always, "URL is not reachable", contrary to stackoverflow.com (and other domains I tested) obviously being reachable. How does one utilize this function to check if a resource is reachable?
The Apple docs for checkResourceIsReachableAndReturnError:
state:
Returns whether the resource pointed to by a file URL can be reached.
Note: "file URL", not Internet or other scheme URL.
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