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 Build an Interactive Story App with Swift 2 Creating a Story Creating an Adventure

The code he has on the screen and that on the Link to code snippet list are different.

The snippet says

struct Adventure {
    static func story(name: String) -> Page {

the code he writes says the below

struct Adventure {
    static var story: Page {

Then, I have an issue with the below,

    let returnTrip = Page(story: .ReturnTrip)) -RETURN TRIP TURNS BLUE/GREEN, NONE OF THE OTHER REFERENCES TO MEMBERS BELOW DO, THEY DO IN HIS VIDEO
    let touchdown = returnTrip.addChoice("Stop and Investigate", story: .TouchDown)
    let homeward = returnTrip.addChoice("Continue Home to Earth", story: .Homeward)

    let rover = touchdown.addChoice("Explore the Rover", story: .Rover)
    let crate = touchdown.addChoice("Open the Crate", story: .Crate)

    homeward.addChoice("Head back to Mars", page: touchdown)
    let home = homeward.addChoice("Continue Home to Earth", story: .Home)

    let cave = rover.addChoice("Explore the Coordinates", story: .Cave)
    rover.addChoice("Return to Earth", page: home)

    cave.addChoice("Continue towards faint light", story: .Droid))
    cave.addChoice("Refill the ship and explore the rover", page: rover)

    crate.addChoice("Explore the Rover", page: rover)
    crate.addChoice("Use the key", story: .Monster)

Remove the extra parenthesis after .ReturnTrip and .Droid to get rid of the errors.

Also, the code difference that you mentioned at the top of your post comes into play later. Use what you see in the video. Otherwise you'll receive an error in your ViewController.

struct Adventure { static var story: Page {

You'll change it to what's in the code snippet later on in "Refactoring the Model Layer"

struct Adventure { static func story(name: String) -> Page {

1 Answer

Jens Hagfeldt
Jens Hagfeldt
16,548 Points

Yes, do as Felix Chu said in his comment and you'll be all good. ("Remove the extra parentheses after .ReturnTrip and .Droid to get rid of the errors.")

I've sent a pm to @pasanpr about this also.