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

Initializers and self

I still have a problem understanding initializers and the self thing. Can someone help me? Thanks

1 Answer

Michael Hulet
Michael Hulet
47,913 Points

When you write a class or struct, you're not writing an object itself, but you're writing a template for what you want an object to look like. init is the special function that sets up an object based on the template you provided by writing a class or struct. The objects themselves are the data structures in memory that were set up based off a class or struct. self is a keyword that refers to the object that's currently being worked on

Thanks, you helped me a lot