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 Building the Music Library and Playlist Models Struct Initialization

Shintaro Fukagawa
Shintaro Fukagawa
3,339 Points

why arent we using self. to initialize the properties?

when we use init to initialize the stored properties, why aren't we using "self."?

1 Answer

This Stack Overflow post answers why using accessor methods in init methods is a bad idea. Using accessor methods will trigger KVO (Key-Value Observing), amongst other things. Also, Apple doesn't recommend it (they even have a section for this very topic in one of their programming guides saying you shouldn't do it).

Shintaro Fukagawa
Shintaro Fukagawa
3,339 Points

thanks for the information! I'll have a read