Treehouse Intermediate Course - Part 15 (Delegation 2)
So there just wasn't a chance yesterday to code! But I'm back today. I was thinking more about creating my own little programme to simulate F1 races and still love that. It could be extended to cricket - a ball by ball approach! But that's something for another time. For now, I'm going to complete this section on delegation; once the race horse example is done, THEN I'm going to play around with the code to see how the F1 sim could work! Cool. Start Time - 08:58 Implementing A Delegate So we need to get any object to adhere to a particular contract, to loosely communicate with race...sounds complex but we're going to find out more! Right so this is the example. This is the delegate - protocol HorseRaceDelegate { func race( _ race: Race , didStartAt time: Date ) func addLapLeader(forLap lap: Int , atTime time: Date ) func race( _ race: Race , didEndAt time: Date , withWinner winner: Horse ) } De...