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

Adam Berkowitz
Adam Berkowitz
2,673 Points

Confused by self (not in the psychological/philosophical sense)

I've been working through the tutorials and I'm still really confused by how "self" gets used. I feel like it should be obvious, but I also feel like I'm missing something. As best I can figure out it's used to refer to an instance or a class you want to call a method on. Am I on the right track?

3 Answers

Stone Preston
Stone Preston
42,016 Points

self refers the instance of the class thats receiving the message or method call.

Holger Liesegang
Holger Liesegang
50,595 Points

Hi Adam,

Stone's definition is precise and absolutely right but you also might want to have a look at Self Keyword

Adam Berkowitz
Adam Berkowitz
2,673 Points

Thank you both very much. I've been away from my computer for a few days. I'll check out the Self Keyword link soon.