I would like to add leaderboards to my SwiftUI app.
I can't find any examples of using loadEntries to load leaderboard values.
I tried the following...
let leaderBoard: GKLeaderboard = GKLeaderboard()
leaderBoard.identifier = "YOUR_LEADERBOARD_ID_HERE"
leaderBoard.timeScope = .allTime
leaderBoard.loadScores { (scores, error) in ...
This results in the following warnings:
- 'identifier' was deprecated in iOS 14.0: Use loadEntriesForPlayerScope:timeScope:range:completionHandler: instead.
- 'timeScope' was deprecated in iOS 14.0: Use loadEntriesForPlayerScope:timeScope:range:completionHandler: instead.
- 'loadScores(completionHandler:)' was deprecated in iOS 14.0: Use loadEntriesForPlayerScope:timeScope:range:completionHandler:.
using loadEntriesForPlayerScope results in the following warning:
- 'loadEntriesForPlayerScope(_:timeScope:range:completionHandler:)' has been renamed to 'loadEntries(for:timeScope:range:completionHandler:)'
Using loadEntries I don't know how to specify the leaderboard identifier.
Here is simple demo of possible approach - put everything in view model and load scores on view appear.