I need to simulate loadScores request on GKLeaderboard. For that i've created extension:
extension GKLeaderboard {
func testLoadScores(completion: @escaping ([GKScore]?, Error?) -> Void) {
...
self.maxRange = 100
}
}
But is says
Cannot assign to property: 'maxRange' is a get-only property
So how i can override this property? Link to description of property: here
I suppose the issue is that maxRange
property is set automatically when loadScores(completionHandler:)
is completed and you should not try to set it on your own
This property is invalid until a call to loadScores(completionHandler:) is completed. Afterward, it contains the total number of entries available to return to your game given the filters you applied to the query.
I suppose you should use range
to get (filter) top N scores
The range property is ignored if the leaderboard request was initialized using the init(playerIDs:) method. Otherwise, the range property is used to filter which scores are returned to your game. For example, if you specified a range of [1,10], after the search is complete, your game receives the best ten scores. The default range is [1,25]. The minimum index is 1. The maximum length is 100.
OR: If you want to get all the scores and there're more than 100 of them it seems you should recursively load scores with increasing ranges, like [1,100], [101,200] ... [1101, 1200].. and so on till you get a range with less than 100 scores. But implementing paging is a better idea because it's possible there are so many scores that they will take too much time to load them all