Hi,
I have an issue with a closure not being called from time to time. The closure should be called after querying the Leaderboard in GameKit:
current.loadEntries(for: GKLeaderboard.PlayerScope.global, timeScope: GKLeaderboard.TimeScope.allTime, range: NSMakeRange(1, 100)) { (entry, entries, val, error) in
for entry in entries! {
print(entry)
self.globalLeaderboard.append(entry)
}
print(error)
print("raise completed")
completed()
print("raised completed")
}
the receiving function looks like this:
svc.loadTop100 {
print("show top 100")
self.showDialog()
}
every 2nd or third time, the closure isn't correctly invoked, but I don't know why. The debug output from the working call looks like this:
nil
raise completed
show top 100
raised completed
and from the non-working call:
nil
raise completed
raised completed
So somehow it never returns.
The function is defined like this:
public func loadTop100(completed: @escaping () -> Void)
Any ideas why this happens? Is there an error with concurrency I haven't thought about?
Thanks,
Mario