Yes, I agree to update the data source. How do I update the data source in topQuarterbacks for a quarterback when the data source is changed in topPlayers?
For example:
I perform the addPlayer action for Patrick Mahomes in topPlayers. At bthe same time, I want to update allPlayers for Patrick Mahomes.
init() {
allPlayers = [PlayerData]()
topRookies = [PlayerData]()
topPlayers = [PlayerData]()
if let playerList = playersReadFromDisk() {
allPlayers = playerList
} else {
allPlayers = [
// Quarterbacks
PlayerData(num: 1, name: "Patrick Mahomes", team: "KC", position: "QB"),
PlayerData(num: 2, name: "Deshaun Watson", team: "HOU", position: "QB"),
PlayerData(num: 3, name: "Aaron Rodgers", team: "GB", position: "QB"),
PlayerData(num: 4, name: "Matt Ryan", team: "ATL", position: "QB"),
PlayerData(num: 5, name: "Baker Mayfield", team: "CLE", position: "QB"),
PlayerData(num: 6, name: "Carson Wentz", team: "PHI", position: "QB"),
PlayerData(num: 7, name: "Jared Goff", team: "LAR", position: "QB"),
PlayerData(num: 8, name: "Cam Newton", team: "CAR", position: "QB"),
PlayerData(num: 9, name: "Andrew Luck", team: "IND", position: "QB"),
PlayerData(num: 10, name: "Drew Brees", team: "NO", position: "QB"),
PlayerData(num: 11, name: "Ben Roethlisberger", team: "PIT", position: "QB"),
PlayerData(num: 12, name: "Dak Prescott", team: "DAL", position: "QB"),
PlayerData(num: 13, name: "Russell Wilson", team: "SEA", position: "QB"),
PlayerData(num: 14, name: "Kyler Murray", team: "ARI", position: "QB"),
PlayerData(num: 15, name: "Tom Brady", team: "NE", position: "QB"),
PlayerData(num: 16, name: "Lamar Jackson", team: "BAL", position: "QB"),
PlayerData(num: 17, name: "Mitchell Trubisky", team: "CHI", position: "QB"),
PlayerData(num: 18, name: "Jameis Winston", team: "TB", position: "QB"),
PlayerData(num: 19, name: "Philip Rivers", team: "LAC", position: "QB"),
PlayerData(num: 20, name: "Kirk Cousins", team: "MIN", position: "QB"),
PlayerData(num: 21, name: "Derek Carr", team: "OAK", position: "QB"),
PlayerData(num: 22, name: "Sam Darnold", team: "NYJ", position: "QB"),
PlayerData(num: 23, name: "Josh Allen", team: "BUF", position: "QB"),
PlayerData(num: 24, name: "Matthew Stafford", team: "DET", position: "QB"),
PlayerData(num: 25, name: "Marcus Mariota", team: "TEN", position: "QB"),
PlayerData(num: 26, name: "Jimmy Garoppolo", team: "SF", position: "QB"),
PlayerData(num: 27, name: "Andy Dalton", team: "CIN", position: "QB"),
PlayerData(num: 28, name: "Eli Manning", team: "NYG", position: "QB"),
PlayerData(num: 29, name: "Nick Foles", team: "JAC", position: "QB"),
PlayerData(num: 30, name: "Joe Flacco", team: "DEN", position: "QB")
]
}
if let topRookiesList = topRookiesReadFromDisk() {
topRookies = topRookiesList
} else {
topRookies = [
PlayerData(num: 1, name: "Josh Jacobs", team: "OAK", position: "RB"),
PlayerData(num: 2, name: "David Montgomery", team: "CHI", position: "RB"),
PlayerData(num: 3, name: "Miles Sanders", team: "PHI", position: "RB"),
PlayerData(num: 4, name: "A.J. Brown", team: "TEN", position: "WR"),
PlayerData(num: 5, name: "N'Keal Harry", team: "NE", position: "WR"),
PlayerData(num: 6, name: "JJ Arcega-Whiteside", team: "PHI", position: "WR"),
PlayerData(num: 7, name: "DK Metcalf", team: "SEA", position: "WR"),
PlayerData(num: 8, name: "Kyler Murray", team: "ARI", position: "QB"),
PlayerData(num: 9, name: "T.J. Hockenson", team: "DET", position: "TE"),
PlayerData(num: 10, name: "Andy Isabella", team: "ARI", position: "WR"),
PlayerData(num: 11, name: "Marquise Brown", team: "BAL", position: "WR"),
PlayerData(num: 12, name: "Deebo Samuel", team: "SF", position: "WR"),
PlayerData(num: 13, name: "Mecole Hardman", team: "KC", position: "WR"),
PlayerData(num: 14, name: "Noah Fant", team: "DEN", position: "TE"),
PlayerData(num: 15, name: "Parris Campbell", team: "IND", position: "WR"),
PlayerData(num: 16, name: "Devin Singletary", team: "BUF", position: "RB"),
PlayerData(num: 17, name: "Darrell Henderson", team: "LAR", position: "RB"),
PlayerData(num: 18, name: "Damien Harris", team: "NE", position: "RB"),
PlayerData(num: 19, name: "Hakeem Butler", team: "ARI", position: "WR"),
PlayerData(num: 20, name: "Diontae Johnson", team: "PIT", position: "WR")
]
}
if let top200PlayersList = topPlayersReadFromDisk() {
topPlayers = top200PlayersList
} else {
topPlayers = [
PlayerData(num: 1, name: "Saquon Barkley", team: "NYG", position: "RB"),
PlayerData(num: 2, name: "Christian McCaffrey", team: "CAR", position: "RB"),
PlayerData(num: 3, name: "Alvin Kamara", team: "NO", position: "RB"),
PlayerData(num: 4, name: "DeAndre Hopkins", team: "HOU", position: "WR"),
PlayerData(num: 5, name: "Michael Thomas", team: "NO", position: "WR"),
PlayerData(num: 6, name: "Ezekiel Elliott", team: "DAL", position: "RB"),
PlayerData(num: 7, name: "Davante Adams", team: "GB", position: "WR"),
PlayerData(num: 8, name: "David Johnson", team: "ARI", position: "RB"),
PlayerData(num: 9, name: "Le'Veon Bell", team: "NYJ", position: "RB"),
PlayerData(num: 10, name: "Todd Gurley II", team: "LAR", position: "RB"),
PlayerData(num: 11, name: "Julio Jones", team: "ATL", position: "WR"),
PlayerData(num: 12, name: "Tyreek Hill", team: "KC", position: "WR"),
PlayerData(num: 13, name: "Odell Beckham Jr.", team: "CLE", position: "WR"),
PlayerData(num: 14, name: "Kerryon Johnson", team: "DET", position: "RB"),
PlayerData(num: 15, name: "Joe Mixon", team: "CIN", position: "RB"),
PlayerData(num: 16, name: "James Conner", team: "PIT", position: "RB"),
PlayerData(num: 17, name: "JuJu Smith-Schuster", team: "PIT", position: "WR"),
PlayerData(num: 18, name: "Antonio Brown", team: "OAK", position: "WR"),
PlayerData(num: 19, name: "Mike Evans", team: "TB", position: "WR"),
PlayerData(num: 20, name: "Dalvin Cook", team: "MIN", position: "RB"),
PlayerData(num: 21, name: "Travis Kelce", team: "KC", position: "TE"),
PlayerData(num: 22, name: "Nick Chubb", team: "CLE", position: "RB"),
PlayerData(num: 23, name: "Patrick Mahomes", team: "KC", position: "QB"),
PlayerData(num: 24, name: "Leonard Fournette", team: "JAC", position: "RB"),
PlayerData(num: 25, name: "Keenan Allen", team: "LAC", position: "WR"),
PlayerData(num: 26, name: "Amari Cooper", team: "DAL", position: "WR"),
PlayerData(num: 27, name: "George Kittle", team: "SF", position: "TE"),
PlayerData(num: 28, name: "Zach Ertz", team: "PHI", position: "TE"),
PlayerData(num: 29, name: "Josh Jacobs", team: "OAK", position: "RB"),
PlayerData(num: 30, name: "Deshaun Watson", team: "HOU", position: "QB")
]
}
}