I am trying to append my annotationsToReturn array and everytime i do that and then check the array count, it always returns 0 as if it never got appended. Could someone help me out please?
func fetchLocations(usersID: [String]){
var annotationsToReturn : [UserAnnotations] = []
for user in usersID {
COLLECTION_USER.document(user).getDocument { snapshot, err in
if err != nil {
print("ERROR")
return
}
let data = snapshot?.data() as? [String:Any] ?? [:]
let latitude = data["latitude"]
let longitude = data["longitude"]
print("latitude: \(latitude as! CLLocationDegrees)")
annotationsToReturn.append(UserAnnotations(user: User(dictionary: data), coordinate: CLLocationCoordinate2D(latitude: latitude as! CLLocationDegrees, longitude: longitude as! CLLocationDegrees)))
}
}
print("count: \(annotationsToReturn.count)")
}