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

Purpose of a designated initializer.

What exactly is the purpose of the designated initializer ? Is it a starting template for the object you are about to create ?

I know how to make one but I'm only about 50% confident I know why I would. Could someone please elaborate ?

Example:

init (title: String, price: Double) {

    self.title = title
    self.price = price

}

1 Answer

roberth3
roberth3
3,940 Points

I'm a beginner too, and I remember this being a question that I had. When you move onto more advanced stuff, you'll see why you need to use it, but you have the right idea about templates.