title: How does performSelectorInBackground and detachNewThreadSelector work?
body: <p>I need to perform an asynchronous function execution because it is blocking the main thread and hence the UI is not available.</p>
  
  <p>After looking at the questions in stackoverflow, I know there are three ways to do asynchronous function.</p>
  
  <p>An example:</p>
  
  <pre><code>[NSThread detachNewThreadSelector:@selector(showSpinner:) toTarget:self withObject:self.view];
  // or 
  [self performSelectorInBackground:@selector(showSpinner:) withObject:self.view];
  // or 
  NSInvocationOperation *invOperation = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(showSpinner:) object:self.view];
  NSOperationQueue *opQueue = [[NSOperationQueue alloc] init];
  [opQueue addOperation:invOperation];
  // or 
  dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
      dispatch_async(dispatch_get_main_queue(), ^{
          [self showSpinner:self.view];
      });
  });
  </code></pre>
  
  <p>My question is how does <code>performSelectorInBackground</code> and <code>detachNewThreadSelector</code> return back to main thread? how do you know that they are done?</p>