title: Trouble understanding array appending
body: <pre><code>func EmptySearchBarList(){
  
  self.PersonalSearchesList = []
  
  currentUserFirebaseReference.child("rooms").observeSingleEvent(of: .value) { (snapshot: FIRDataSnapshot) in
  
  
      if let snapshots = snapshot.children.allObjects as? [FIRDataSnapshot] {
          for snap in snapshots {
  
              print("snap")
              print(self.PersonalSearchesList.count) // Calling 0 every single time
  
              DataService.ds.REF_INTERESTS.child(interestKey).observeSingleEvent(of: .value, with: { (snapshot: FIRDataSnapshot) in
  
                  if snapshot.value != nil {
  
                      if let users = (snapshot.value! as? NSDictionary)?["users"] as? Dictionary&lt;String,AnyObject&gt; {
  
                          DataService.ds.REF_USERS.child(topUser).child("pictureURL").observeSingleEvent(of: .value, with: { (snapshot: FIRDataSnapshot) in
  
                              self.PersonalSearchesList.append(eachSearch)
                              print("first one")
                              print(self.PersonalSearchesList.count)
                          })
                      }
                  }
              })
  
          }
  
          print("Second one")
          print(self.PersonalSearchesList.count)
  
          print("Calling to set my sorted PersonalSearchesList")
          self.mySortedList = self.PersonalSearchesList.sorted{ $0.users &gt; $1.users }
  
      }
  }
  initialLoadOver = true
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/wpqhP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wpqhP.png" alt="The print logs"></a></p>
  
  <p>What code I'm trying to ultimately run is this : </p>
  
  <pre><code> var mySortedList = [Interest](){
      didSet{
          print("this was called")
          let myCount = mySortedList.count
          print(self.PersonalSearchesList.count)
          print(myCount)
  
          self.tableView.reloadData()
      }
  }
  </code></pre>
  
  <p>The attempt is to load up my PersonalSearchesList array, and once the snap in snapshots is done running, I'm setting MySortedList equal to PersonalSearchesList and reloading the tableview.</p>
  
  <p>What I don't understand is why  the prints are coming out like they are.  The snap/ 0's are coming from the top of my for snap in snapshots. It seems like it should instead be snap / 1 , snap / 2, snap / 3. </p>
  
  <p>The code to be called when the snaps are done is correct in the timeline, once the snaps have gone through that code runs. What doesn't make sense is why it's not until after that the items are actually being appended to PersonalSearchesList. Becuase of how everything is Im' setting my filtered array to an empty personal searches array and then afterwards I'm filling it up.</p>
  
  <p>Any ideas here?</p>
  
  <p>edit:</p>
  
  <pre><code> var dispatchGroup = DispatchGroup()
          dispatchGroup.enter()
          dispatchGroup.leave()
  
          dispatchGroup.notify(queue: DispatchQueue.global(), execute: {
  
          })
  </code></pre>