0

Does anyone know where I can find the documentation on behaviour for NSURLConnection?

I"m trying to find out what NSURLConnection does when you send an asynchronous request, but there is no network. Does NSURLConnection time out, or does it just wait until iOS gets a network?

I need to send an asynchronous request containing data to a server, but the app will be used out in the field, where network connections are spotty at best. In that case, I want the app to upload the data as soon as there is a network to do so.

Edit: Looking at reachability, it can't notify me if internet service comes back on (for example, you come back into range of a cell tower). Does anyone know if it is even possible for my application to be notified by the system when there is an internet connection so that it can do its thing?

Daniel
  • 458
  • 7
  • 21

3 Answers3

1

Yes it times out when no network is available.

You should use reachability to achieve such a behavior. You'll be notified when you have network back, and will be to upload data ASAP.

Here is your starting point perhaps : iPhone reachability checking

Also this one : ARC and GCD Compatible Reachability Class for iOS and MacOS. Drop in replacement for Apple Reachability the one I use

Community
  • 1
  • 1
Vaseltior
  • 1,226
  • 15
  • 27
1
-(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
    //When there is no internet connection, you will get an error right away
}
Jesse Gumpo
  • 4,777
  • 1
  • 20
  • 29
0

Probably you're looking for Reachability

Answering your question, the error may be either timeout or "The Internet connection appears to be offline.", depending on the circumstances

epolyakov
  • 75
  • 1
  • 4