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

Xcode is crashing after doing what this video states.

This thing keeps saying that Communication with the playground service was interrupted unexpectedly. It worked flawlessly on previous videos prior to this one.

// Convenience Initializer import UIKit

//struct does not need an initializer, one is provided by default //stored properties, constants or variables

/quadcopter.price = 199.99/

class Product { //base class and super class of clothing let title: String var price: Double = 0.0 //Xcode made me change to Var from let

init(title: String, price: Double) {
    self.title = title
    self.price = price
}

func discountedPrice(percentage: Double) -> Double {
    return price - (price * percentage / 100)
}

}

enum Size { case Small, Medium, Large init () { self = .Small } } class Clothing: Product { //subclass var size = Size() let designer: String

init (title: String, price: Double, designer: String) {
    self.designer = designer
    super.init(title: title, price: price)
}

convenience init(title: String) {
   self.init(title:title,price:99,designer:"Calvin Klein")
        }


override func discountedPrice(percentage: Double = 10.0) -> Double {
    return super.discountedPrice(percentage)
}

}

var tshirt = Clothing(title: "Vintage") tshirt.title tshirt.price tshirt.designer tshirt.discountedPrice(50) tshirt.size

let quadcopter = Product(title: "Quadcopter", price: 499.99)