title: Parse.com query and application design issue: A long-running operation is being executed on the main thread
body: <p>In my <strong>iOS</strong> app I need to retrieve some values by using <code>PFObject</code> queries. And when these are all loaded, the app should continue doing some more stuff. </p>
  
  <pre><code>func processTransaction(){
  
     .. some code to prepare my 2 queries
  
     var balance1 = balance1Query.getFirstObject() as PFObject;
     var balance2 = balance2Query.getFirstObject() as PFObject;
  
     .. after these are loaded i have to update them, and 'release' the screen to the user. 
  }
  </code></pre>
  
  <p>Now, when using this <code>.getFirstObject()</code> method, I get a warning in my <strong>Xcode</strong> debug window saying: </p>
  
  <blockquote>
    <p>A long-running operation is being executed on the main thread.</p>
  </blockquote>
  
  <p>Of course I did some research, and every answer I read talks about using 
  <code>getObjectInBackgroundWithId</code>, which then moves the execution of these queries to the background (I guess doing so it puts them on a new thread.)</p>
  
  <p>But my question is, how should I structure my code / design, to make sure that both objects are loaded, before the code continues to work with these objects? </p>
  
  <p>I tried some things, and create some code like below, but to me it feels like this isn't the right approach. Can't think of what a mess this will become when I have to load and make sure that 4 or 5 objects are loaded. </p>
  
  <pre><code>balanceQuery1.getFirstObjectInBackgroundWithBlock{
      (balance1: PFObject!, error1: NSError!) -&gt; Void in
      if error1 == nil {
          balanceQuery2.getFirstObjectInBackgroundWithBlock{
              (balance2: PFObject!, error2: NSError!) -&gt; Void in
              if error2 == nil {
                  ... processing here..
              }
      }
  }
  </code></pre>