title: Swift 2 - How can I run a code after an asynchronous method?
body: <p>I am using the following asynchronous method to get data from Firebase, ref is just my database url.  It's working perfectly but I want to run the for loop after the data has been loaded.  Because it's an asynchronies method, it starts to get the data from the database and immediately goes to the for loop.  Anyway I can get it to wait till the data is downloaded then run the for loop?  Please help! :-)</p>
  
  <pre><code> ref.observeSingleEventOfType(.Value, withBlock: { snapshot in
          print(snapshot.value.objectForKey("Table")!)
          s = snapshot.value.objectForKey("items:")! as! String
  
          Str = s.componentsSeparatedByString(",")
  
  
      })
  
      for(var i = 0 ; i &lt; Str.count ; i++){
          print(Str[i])
      }
  </code></pre>