Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS Object-Oriented Swift Value vs Reference Types Final Exam - Solution

not working on my Xcode?


Create a base class called Shape which will have 2 properties: sides and name Create a subclass called Square, it will also have 2 properties called: sideLength and area. The area property will be a computed property with getter and setter methods. Add a designated initializer to Square which accept all three properties: sides, name and sideLength Add a convenience initializer to Square that will accept only the sideLength and provide default values. 4 for sides and “Square” for name Create an instance of Square using the convenience initializer?

MY Answer same as shown in the video by Amit.

class Shape { let side: Int let name: String

init (side: Int, name: String){

    self.side = side
    self.name = name



class Square: Shape { var sideLength: Double = 0.0 var area: Double = 0.0 {

get {
return sideLength * sideLength

set {
sideLength = sqrt(newValue)

init(name: String, side: Int, sideLength: Double){

self.sideLength = sideLength
super.init(sides: sides, name: name)

convenience init(sideLength: Double) {
    self.init (name: "square", side: 4,  sideLength: sideLength)


let square = Square(sideLength: 20) square.name square.side square.sideLength square.area square.area = 100 square.sideLength

still getting error at two stages -->


super.init(sides: sides, name: name)

error = use of unresolved identifier


var area: Double = 0.0 {

error = cannot call vale of non-funtional type???