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 Inheritance Convenience Initializers

Convenience Initializers Quiz Question #1

in the quiz afterwards this video we get the following syntax :

class RoundButton: Button {
  var cornerRadius: Double = 5.0

  init(width:Double,height:Double,cornerRadius:Double){
    self.cornerRadius = cornerRadius
  }  

  init(length:Double) {
     self.init(width:length, height:length,cornerRadius)
  }
}

we are being asked if :

Is the following a valid convenience initializer? If not, then what is missing from its definition?

the available answers are :

A. "No, it isnt valid because it needs to call the designited initializer of its super class"

B. "No, it isnt valid bcause its missing the keyword convenience"

C. "Yes it is completely valid"

well its pretty obvious that the thing missing is the "convenience" declaration of the convenience initializer , however my question is : why didnt the designited initializer above it call the super.init of its Super Class ? it does take in all the parameters of the Super Class but when initializing it's only referring to "cornerRadius"

am i missing something here ?

Lawrence Yeo
Lawrence Yeo
3,236 Points

I am also wondering about this too. I thought that the designated initializer needed to call the super.init as well.