I am using a Firebase in my app, it queries through a lot of users and gets the specific data that is needed, but when it starts querying - the rest of the function keep running too, instead of just querying so I can't understand when it ends.
For example in this code:
ref.observeEventType(.ChildAdded, withBlock: { snapshot in
let user = snapshot.value!.objectForKey("User")
let name = (user!["Name"])! as! String
print("name")
})
print("done")
Let's say we have 3 users in the Firebase Database - the printed code will be:
done
nameuser1
nameuser2
nameuser3
(or the done
will be somewhere between the nameusers, depends on your internet connection - BUT it won't be the the last)