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 a Playlist Browser with Swift Working With Multiple View Controllers Review: Working With Multiple View Controllers

Lee Ravenberg
Lee Ravenberg
10,018 Points

A segue an instance of UIStoryBoard?!

During the review-working-with-multiple-view-controllers quiz, it is asked what a segue is. The answer appears an instance of the UIStoryBoard class.

Now I am curious where to learn about this class structure; when I read the API reference on UIStoryBoardSegue, it says to inherit from NSObject, not UIStoryBoard.

Anyone?

2 Answers

Chris McKnight
Chris McKnight
11,045 Points

It says that UIStoryboardSegue inherits from NSObject. NSObject is the base class that all objects inherit from.

In the subclassing notes section, they say to inherit from UIStoryboardSegue when you want custom transitions.

The quiz references the wrong class. It should be UIStoryboardSegue in the quiz which you have discovered. UIStoryboard is used under the hood with the info.plist to load the storyboard and run it. You can programmatically do this as well if you wanted to switch between storyboards with your code.

Lee Ravenberg
Lee Ravenberg
10,018 Points

Phew I thought I was seeing things

Robert Baghai
Robert Baghai
5,492 Points

A segue is a way to transition from one ViewController to another. In addition to actually navigating to a new ViewController, a segue also allows you to pass data from one ViewController to another if you so choose to do so.

Lee Ravenberg
Lee Ravenberg
10,018 Points

Yes, that is absolutely true. To instantiate a UIStoryboardSegue programmatically, you have to pass two UIViewController methods (source and destination) to the initializer method.

But the question remains; How is it that the quiz is stating that a segue is an instance of a UIStoryBoard?