Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Delegation in iOS The Delegate Pattern Racing Horses

Taylor Cawiezell
Taylor Cawiezell
6,261 Points

Incorrect teachers sample code? I have the updates needed for Swift 4 Xcode 10.0.0.

You need to update the start function as follows.

func start() {
        RunLoop.main.add(timer, forMode: RunLoop.Mode.default)
        tracker.updateRaceStart(with: Date())
        print("Race in progress...")
    }

3 Answers

Johnny Nguyen
Johnny Nguyen
3,875 Points

forMode: .default

When you see this situation, the best action is to type "." and it will show you all the options. Just choose one with default.

Raymond Choy
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Raymond Choy
iOS Development with Swift Techdegree Graduate 11,187 Points

class Race { let laps: Int let lapLength: Double = 300 let participants: [Horse]

let tracker = Tracker()

// The above line of teacher's code still returns a compile error of "Use of unresolved identifier 'Tracker' // How do I fix this on X-code version 10.1?

lazy var timer: Timer = Timer(timeInterval: 1, repeats: true) { timer in
    self.updateProgress()
}

In Xcode version 10.2 it now shows this as an error saying "Type of expression is ambiguous without more context", not sure what to do here...

Olivier Van hamme
Olivier Van hamme
5,418 Points

Saved by Auto Complete when re-typing the RunLoop formula :

func start() {
    // RunLoop.main.add(timer, forMode: .RunLoop.Mode.default)
    RunLoop.main.add(timer , forMode: .default)
    tracker.updateRaceStart(with: Date())
    print("Race in progress...")
} // END func start()

The race compiles now .