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 Object-Oriented Swift Classes in Swift Recap: Classes

Martel Storm
Martel Storm
4,157 Points

Swift 3 Object Orientation I got this wrong on the quiz. Can someone please explain? I'm clueless

How do we refer to an instance of a class or a struct from within the definition of an object? Class.self My answer but I was pretty unsure of it Struct.self self this

1 Answer

To refer to a class inside of a class, you just need to say self.

:point_right: Keep in mind that you are only able to do this when the code is inside this class!

When you are outside of the class (in code), you must refer to the class by using the class name.

I hope this helps. :grin:

~Alex