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 Intermediate Swift Extensions and Protocols Protocol Extensions

Jordan Leahy
Jordan Leahy
25,054 Points

What are some common uses cases of extensions is a simple app?

What are some common uses cases of extensions is a simple app?

1 Answer

Nathan F.
Nathan F.
30,773 Points

Some use cases of extensions in a simple app would be

  1. Adding functionality or convenience methods to Apple-provided types. For example, adding a method to UIColor that takes a hex value (like #F3DDC5) and generates a color.

  2. To extend a type of your own and make it conform to a protocol or delegate. Yes, you could simply add this protocol conformance to the type's definition, but if your struct or class is large, an extension can improve legibility and code organization.