title: Reachability code blocking main thread
body: <p>I'm currently working on an app that requires me to check for reachability.</p>
  
  <p>Owing to that, I started looking stuff up and found DDG and Apple's code. I decided to go with Apple's latest reachability code.</p>
  
  <p>I imported that, and as suggested in Apple's sample, I came up with the following way to register:</p>
  
  <pre><code>[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(notificationHandler:) name:kReachabilityChangedNotification object:nil];
  
      //check for local connection and start notifier
      client = [[Reachability reachabilityForInternetConnection] retain];
      [client startNotifier];
  
      //check for server connection and start notifier
      server = [[Reachability reachabilityWithHostName:SERVER_HOST_NAME] retain];
      [server startNotifier];
  
      //check for other server and start notifier
      otherServer = [[Reachability reachabilityWithHostName:OTHER_SERVER_HOST_NAME] retain];
      [otherServer startNotifier];
  </code></pre>
  
  <p>What I observed when I ran the app was that this code started blocking the UI (blocking the main thread). I could not interact with other UI elements till the host name was resolved. Now I know that Apple has stated a warning about DNS resolution and making it asynchronous. </p>
  
  <p>My question would be, how do I go ahead and make it asynchronous?</p>
  
  <p>Do I spawn another thread and keep it running so as to not "release" the Reachability object?</p>
  
  <p>Thanks in advance for your help! :)</p>