You can specify a timeout in your NSURLRequest
object. One way to do this is to construct it via the requestWithURL:cachePolicy:timeoutInterval:
method. (You can pass in the default NSURLRequestUseProtocolCachePolicy
cachePolicy parameter if you don’t want to worry about that part.) The timeout is a floating-point value in seconds, as are basically all time intervals in the iPhone SDK.
Also make sure your NSURLConnection
‘s delegate is set and responds to the connection:didFailWithError:
method. A connection always calls either this method or connectionDidFinishLoading:
upon connection completion.