0

I have an application where it needs to connect to a URL. This URL is a XML link.

Now my question is, when I will run application then I want to check that application is connected to the given URL. Actually all time I will check internet is available or not?

I have found some answers on StackOverflow. They said to use reachability library, but I don't want to use. Because I just only want to see when I will call url then internet connection available or not thats all.

Robin
  • 7,527
  • 6
  • 51
  • 82
Emon
  • 970
  • 3
  • 10
  • 28
  • As David said - use Reachability. Sample code can be found in here http://stackoverflow.com/questions/1083701/how-to-check-for-an-active-internet-connection-on-iphone-sdk – nadavhart Nov 20 '11 at 11:12

1 Answers1

1

The reachability code is the best thing to use - it will give you an answer immediately. If you try to connect with a URL and it isn't reachable you might not know until the network request times out, which may take a long time - up to several minutes in some cases. You'll have to do this in a background thread to avoid blocking the UI while you wait. This in turn means you'll have to deal with the 'unknown' condition in the UI, and finally deal with notifications and passing the result around inside your app.

Building in the reachability code really is the solution.

DavidA
  • 3,092
  • 23
  • 35