Create a class called Parent
with a title
property and write an init
and deinit
method for your class.
Write a subclass called Child
.
My problem is putting this into the code (call super.init(title:)
and pass on the title
parameter.
class Parent {
let title: String
init(title: String){
self.title = title
print("\(title) is initialized")
}
deinit {
print("\(title) is being deinitialized.")
}
}
class Child: Parent {
let subtitle: String
init(subtitle: String){
self.subtitle = subtitle
// i'm supposed to call a super.init, how
print("\(subtitle) is initialized")
}
deinit {
print("\(subtitle) is being deinitialized.")
}
}