Моя функция просто зацикливается на операторе print и не входит в ref db.collection. Я что-то здесь не так делаю? Спасибо за любую помощь. Я не совсем уверен, где go, это лучший способ для l oop выбросить большую часть данных
func rat(){
var x = 0
while x != self.uniqueNumber{
let db = Firestore.firestore()
let indexString = String(x)
print(x)
let ref = db.collection("leaderboard").document(indexString)
ref.getDocument { (document,error) in
if error != nil{
print("cant get data")
}
if document != nil && document!.exists{
if let documentdata = document?.data() {
self.check = documentdata["points"] as! Int
self.uid = documentdata["uid"] as! String
x = x+1
print(x)
print("The user's ID was\(self.uid)")
if (self.check > self.firstPlace.placePoints){
self.secondPlace.placePoints = self.firstPlace.placePoints
self.secondPlace.placeNames = self.firstPlace.placeNames
self.firstPlace.placePoints = self.check
self.firstPlace.placeNames = self.uid
print("First Place was set to:\(self.firstPlace.placeNames)")
}else if(self.check < self.firstPlace.placePoints && self.secondPlace.placePoints < self.check){
self.thirdPlace.placePoints = self.secondPlace.placePoints
self.thirdPlace.placeNames = self.secondPlace.placeNames
self.secondPlace.placePoints = self.check
self.secondPlace.placeNames = self.uid
print("Second Place was set to:\(self.firstPlace.placeNames)")
}else if(self.check < self.secondPlace.placePoints && self.thirdPlace.placePoints < self.check){
self.thirdPlace.placePoints = self.check
self.thirdPlace.placeNames = self.uid
print("Third Place was set to:\(self.firstPlace.placeNames)")
}
}
if(x == self.uniqueNumber!-1){
print("This is the escape out")
self.setGuys()
}
}
}
}
}