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 Story Segments as Enum Members

Boris Likhobabin
Boris Likhobabin
3,581 Points

What is the point of having an extension on enum?

Can somebody explain what is the benefit of having an extension on a Story enum in this video? Why don't we just include those properties from extension within an enum? How does this change functionality?

And in general (on other objects) why is better to have an extension rather than including those "extended" features within an object?

I know one way wherer this is useful (when we don't have access to the object (like Apple's objects that we use but cannot observe)) So we can add something on to them but with our objects I just don't see how this is useful. Please help!

1 Answer

David Papandrew
David Papandrew
8,386 Points

I think a lot of people use extensions to organize their code better and for readability purposes. You are correct that it doesn't really change the underlying functionality.

Here's an article that helped me with the topic: https://www.natashatherobot.com/using-swift-extensions/