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 Structure of a Page

Tony Teixeira
Tony Teixeira
14,823 Points

ERROR: Expected member name or constructor call after type name

class Page {
    let story = Story // Expected member name or constructor call after type name
    typealias Choice = (title: String, page: Page)

    var firstChoice: Choice?
    var secondChoice: Choice?

    init(story: Story) {  // Cannot assign value of type 'Story' to type 'Story.Type'
        self.story = story
    }
}

Keep getting errors, is this a change in Swift or am I making an error?

Justin Janes
Justin Janes
5,904 Points

I'm hitting this same problem two hours after you, I think it may be a gap between the video content and where Swift currently is.

1 Answer

Michael Hulet
Michael Hulet
47,913 Points

What I bet you're meaning to do on line 2 of your example is declare a constant called story of type Story, but your code is written using the assignment operator, which is not correct. In other words, I bet you meant to use a colon (:) instead of an equals sign (=). Try changing the second line to this and see what happens:

let story: Story
Tony Teixeira
Tony Teixeira
14,823 Points

Ahh absolutely what I was trying to do. I was wondering why it was not throwing an init error before I added the init method. Makes sense, my error... thanks!