October 2017
Intermediate to advanced
210 pages
5h 32m
English
Now, let's see how to use the data access layer by creating a team and a player:
var bos = Team( teamId: 0, city: "Boston", nickName: "Red Sox", abbreviation: "BOS") try? TeamBridge.save(&bos) var ortiz = Player( playerId: 0,firstName: "David", lastName: "Ortiz", number: 34, teamId: bos.teamId, position: Positions.designatedHitter) try? PlayerBridge.save(&ortiz)
In this code, we created one team, the Boston Red Sox and one player, David Ortiz. We also put David Ortiz on the Boston Red Sox team, by assigning Red Sox team id to the player's team id. This information can now be retrieved, as shown in the following code:
if let team = try? TeamBridge.retrieve(0) { print("--- \(team?.city)") } if let player = try? ...Read now
Unlock full access