I’d like some advice on how to detect a “bad” URL before issuing an NSURLConnection call. By bad, I mean a non-existent host (e.g., http://www.no_such_host.com). I would need to first parse the URL to get just the host (suggestions welcome!) and then would like to see if the host actually is registered.
Is there a simple approach to using the DNS Resolver lookup, available in the iOS libraries?
If I were you, I would just go with the connection, then just catch in
NSURLConnectionDelegate‘s– connection:didFailWithError:method the error.NSURLConnectionwill still go to resolve the URL that you enter. The errors thatNSURLConnectionwill throw can be found in the Foundation Constants Reference (look forNSURLErrorDomain). If I remember correctly, the error that will be thrown isNSURLErrorCannotFindHost.