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 trialJordan Leahy
25,054 PointsWhat 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.
30,773 PointsSome use cases of extensions in a simple app would be
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.
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.