Property observers are only called when the property’s value is set outside of initialization context.
defer
can change situation 😊
class Member {
var ageMember: Int! {
didSet {
print("Function: \(#function)")
}
}
init(age: Int) {
self.ageMember = age
}
}
class User {
var ageUser: Int! {
didSet {
print("Function: \(#function)")
}
}
init(age: Int) {
defer {
self.ageUser = age
}
}
}
Function: ageUser
Comments !