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 Objective-C Building a Music Library Model Creating a Music Library

self.library in initialiser method

So, Pasan uses the self keyword in the initialiser method of the MusicLibrary implementation file to pass data to the library property. In a previous lesson, he mentioned that self should not be used when we refer to a property in the initialiser method due to the fact that the property might not be ready for use at that time. Instead, we should use the back up instance variable i.e _library instead of self.library. Could anyone shed some light on this issue?

1 Answer

You are right and i did little researches about the subject. As far as i know :

_library gives direct access to the memory location.

self.library uses the setters and getters

hope it helps :)

Andre Kovac
Andre Kovac
5,588 Points

So was the code wrong, which Pasan presented in the video then?