I'm wondering, when/how does the didSet on an outlet actually trigger?
For example :
@IBOutlet weak var modifyButton: UIButton! {
didSet {
modifyButton.layer.cornerRadius = 9
}
}
Outlet properties initialized as nil when class just initialized. They will have values later, when objects will be initialized from nib. First step, when you can be sure that all properly configured outlet properties have nonnil values is viewDidLoad
. So, didSet
observer on this properties will be called just before viewDidLoad
. Because all of this you need to be careful with outlet properties: for example you will receive nil if you will try access them in prepareForSegue
method