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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![nicholasdevereaux](https://secure.gravatar.com/avatar/4a649752dbaf8f07d05ad56c3538b8c4?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
nicholasdevereaux
16,353 PointsprepareForSegue function
The last line of my code only likes 'pageController.page = Adventure.story(name: String)'
It only auto populates 'story(name: String)' after Adventure. The code in the video auto populates just 'story' after Adventure.
I must have done something wrong in another file. Here is a copy of my prepareForSegue function.
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { if segue.identifier == "startAdventure" { if let pageController = segue.destinationViewController as? PageController { pageController.page = Adventure.story(name: String) }
![nicholasdevereaux](https://secure.gravatar.com/avatar/4a649752dbaf8f07d05ad56c3538b8c4?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
nicholasdevereaux
16,353 PointsWhen I leave it as pageController.page = Adventure.story, I get an error saying I cannot assign value of type '(String) -> Page' to type 'Page?'
4 Answers
![Ginny Pennekamp](https://uploads.teamtreehouse.com/production/profile-photos/531472/micro_GB_the_frog.jpg)
Ginny Pennekamp
31,466 PointsI made the same mistake so I checked the download project files to see what went wrong.
In InteractiveStory.swift, I had the code:
struct Adventure { static func story(name: String) -> Page {
but it should have read:
struct Adventure { static var story: Page {
Once I changed it, the error in PageController.swift went away.
![Nat Rogers](https://secure.gravatar.com/avatar/e7ad7a65446ffe2ca839df981d5f8242?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Nat Rogers
7,433 Pointscan you explain why this needed to be changed?
![nicholasdevereaux](https://secure.gravatar.com/avatar/4a649752dbaf8f07d05ad56c3538b8c4?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
nicholasdevereaux
16,353 PointsThank you so much!
![nicholasdevereaux](https://secure.gravatar.com/avatar/4a649752dbaf8f07d05ad56c3538b8c4?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
nicholasdevereaux
16,353 PointsIf I remember correctly, the code snippet provided was the end result of the InteractiveStory.swift file. However, the point I was at in the tutorial, my InteractiveStory.swift file should have read - struct Adventure { static var story: Page {, so your viewController should be pageController.page = Adventure.story.
As I progressed, it changed the InteractiveStory.swift file to read - struct Adventure { static func story(name: String) -> Page { (which is what I had to begin with) which changed viewController to Adventure.story(name: String).
They may have updated the code snippet since then. It's been awhile so I hope this is helpful.
![Abdulwahab Alansari](https://secure.gravatar.com/avatar/aeb5f9ce9b6d334d295b9b0a84c4179b?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Abdulwahab Alansari
15,151 PointsWell, I had been wondering why the story method in the Adventure structure had "name: String" parameter especially that Pasan didn't use it in the method implementation, then I came across the error nicholasdevereaux encountered and immediately I knew it was the "name: String" parameter in the story method, I removed it and it worked. However, I still don't know why Pasan added it in the first place.
Hope this could help the students coming after me :)
nicholasdevereaux
16,353 Pointsnicholasdevereaux
16,353 PointsWhen I leave it as pageController.page = Adventure.story, I get an error saying I cannot assign value of type '(String) -> Page' to type 'Page?'