You can see if a URL is valid or not by doing the following:
NSString *urlString = ... // some URL to check
NSURL *url = [NSURL URLWithString:urlString];
if (url) {
// valid URL (meaning it is the proper format)
}
To see if the URL exists in the Internet, you need to perform a HEAD request and check the result. This is more efficient than loading all of the data for the URL.
NSMutableURLRequest request = [NSMutableURLRequest requestWithURL:inURL];
[request setHTTPMethod:@"HEAD"];
NSURLConnection connection = [NSURLConnection connectionWithRequest:request delegate:self];
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
if ([(NSHTTPURLResponse *)response statusCode] == 200) {
// url exists
}
}