title: iPhone - Help with MBProgressHUD, Sudzc, Web Services and NSThread
body: <p>I have the following code, which connects to a web service and returns an array of Categories.</p>
  
  <p>I am using the following wrapper for SOAP web services:</p>
  
  <p><a href="http://www.sudzc.com/" rel="nofollow">http://www.sudzc.com/</a></p>
  
  <p>..and the following <code>MBProgressHUD</code> for the activity indicator:</p>
  
  <p><a href="https://github.com/jdg/MBProgressHUD" rel="nofollow">https://github.com/jdg/MBProgressHUD</a></p>
  
  <p>I would like to have a HUD progress indicator indicate that it's connecting and grabbing results. I'm currently using <code>MBProgressHUD</code> to achieve the desired effect, however I'm noticing that it's not quite working properly. The progress indicator disappears before the actual cells in my <code>tableView</code> are loaded and displayed. I also use the <code>MBProgressHUD</code> in different areas of my application, but usually every time I connect to the web service to grab results.</p>
  
  <p>Could someone lead me in the right direction as to how to fix the below code to work properly? I think it may relate to the fact that the callback method is fired after the progress indicator is displayed. Not quite sure how to implement <code>MBProgressHUD</code> properly with a callback method.</p>
  
  <p>This is my horrible attempt at "trying" to get it working.</p>
  
  <pre><code>- (void)showHUD {
      HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view];
  
      // Add HUD to screen.
      [self.navigationController.view addSubview:HUD];
  
      // Register for HUD callbacks so we can remove it from the window at the right time.
      HUD.delegate = self;
  
      HUD.labelText = @"Loading";
  
      // Show the HUD while the provided method executes in a new thread
      [HUD showWhileExecuting:@selector(runLocalNotificationHandler) onTarget:self withObject:nil animated:YES];
  }
  
  - (void)runLocalNotificationHandler {
      NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
  
      [self performSelectorOnMainThread:@selector(connectToService) withObject:nil waitUntilDone:YES];
  
      [pool release];
  }
  
  - (void)connectToService {
      Service1 *service = [[Service1 alloc] init];
      [service GetCategories:self action:@selector(handlerGetCategories:)];
      [service release];
  }
  
  - (void)handlerGetCategories:(id)value {
      // parse objects returned from array, populate array, reload table view data, etc
  }
  </code></pre>