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 trialRicardo Gonzalez
2,286 PointsWhat does it mean by instance?
Forgot what an instance is so can someone help?
class Button {
var width: Double
var height: Double
init(width:Double, height:Double){
self.width = width
self.height = height
}
class RoundButton: Button {
var cornerRadius = 5.0
}
}
Caleb Kleveter
Treehouse Moderator 37,862 PointsGary, just thought I might tell you that if you want to answer a question you should post it as an answer vs. a comment. One reason is because you can get up-voted and marked as best answer on answers, but not comments.
Gary Calhoun
10,317 PointsOh thank you I see the section now I have to scroll down to the answer section lol
Greg Kitchin
31,522 PointsI've not done the IOS course, but in general, an instance is a working object, that is derived from a class. You can imagine the class as a cookie cutter, that has it's own characteristics, and when you want a cookie (the instance), you create one, using the cutter as a template.
1 Answer
Caleb Kleveter
Treehouse Moderator 37,862 PointsFirst, the challenge won't let you pass if the class you create is inside the first one so you need to move it out; second, instance is simply creating a variable or constant and giving it a value, like this:
var rounded = RoundButton(width: 4.0, height: 2.0)
Happy coding!
Gary Calhoun
10,317 PointsGary Calhoun
10,317 PointsI think an instanced object or variable is a clone copy and if the original changes the instanced clone version changes as well. I am not 100 percent sure though.