title: dispatch_async in return method Objective-C
body: <p>I have been trying to use <code>dispatch_async</code> in a method that returns a result. However, I observed that the method returns before executing the <code>dispatch_async</code> block. Due to this I'm not getting the results I expect. Here is some code that demonstrates my problem.</p>
  
  <pre><code>-(BOOL) isContactExists {
      BOOL isContactExistsInXYZ = YES;
      UserId *userId = contact.userId;
      dispatch_async(dispatch_get_main_queue(), ^
      {
          iOSContact *contact = [iOSContact contactForUserId:userId];
          if (nil == contact)
          {
            isContactExistsInXYZ = NO;
          }
      });    
  
      return isContactExistsInXYZ;
  }
  </code></pre>
  
  <p>This method <code>isContactExists</code> is called somewhere else and based on the response from that method I have to do some stuff. But every time, the value of <code>isContactExistsInXYZ</code> is not what I expect. How do I handle <code>dispatch_async</code> in this situation?</p>