Learn how to hook up the leaderboard data model to the leaderboard view.
This is a companion discussion topic for the original entry at https://www.raywenderlich.com/28797859-your-first-ios-swiftui-app-polishing-the-app/lessons/39
Learn how to hook up the leaderboard data model to the leaderboard view.
Errata suggestion:
VStack(spacing: 10) {
ForEach(game.leaderboardEntries.indices) { i in
let leaderboardEntry = game.leaderboardEntries[i]
RowView(index: i + 1, score: leaderboardEntry.points, date: leaderboardEntry.date)
}
}
should be (to suppress a warning)
VStack(spacing: 10) {
ForEach(game.leaderboardEntries.indices, id: .\self) { i in
let leaderboardEntry = game.leaderboardEntries[i]
RowView(index: i + 1, score: leaderboardEntry.points, date: leaderboardEntry.date)
}
}
Transcript typo suggestion: the parameter name in the test data init should be score instead of points.