0

Currently i am following thread to check wheather my internet is active or not in my application, but as it is taking time to give the response ,so this will freeze my UI.

So is there any way to implement it without freezing UI(like NSOperation).

Community
  • 1
  • 1
user1227928
  • 831
  • 1
  • 12
  • 27
  • You'll need to post your code or no one will be able to answer. Reachability works fine, it must be something you did wrong. – He Shiming Apr 11 '12 at 15:08

2 Answers2

0

If the internet is indeed down, it takes time. It is limitation of Apple's API. We have to live with it or put a timer to cancel the operation after 30 secs or so. But if a genuine response especially via GPRS takes more than 30 secs, you will be canceling that too if you put timer condition.

Satish
  • 170
  • 3
  • 12
0

Alternatively, you could check for internet status asynchronously and display an ActivityIndicator or similar in the main thread. This means that you create a new thread which will run parallel with your main thread (in your case, the GUI that are freezing).

Kasper Munck
  • 4,173
  • 2
  • 27
  • 50
  • Do you have any example/sample tutorial , how to do this ? – user1227928 Apr 15 '12 at 19:54
  • Have a look at http://www.fieryrobot.com/blog/2010/06/12/threading-is-dead-long-live-threading/ it explains how to use dispatch_async, which allows you to run a block of code in another thread. You might need to tweek Reachability a bit (eg. to post a notification to NSNotificationCenter when the result is ready). – Kasper Munck Apr 17 '12 at 06:26