Quantcast
Channel: What is the purpose of willSet and didSet in Swift? - Stack Overflow
Viewing all articles
Browse latest Browse all 12

Answer by orkoden for What is the purpose of willSet and didSet in Swift?

$
0
0

One thing where didSet is really handy is when you use outlets to add additional configuration.

@IBOutlet weak var loginOrSignupButton: UIButton! {  didSet {        let title = NSLocalizedString("signup_required_button")        loginOrSignupButton.setTitle(title, for: .normal)        loginOrSignupButton.setTitle(title, for: .highlighted)  }

Viewing all articles
Browse latest Browse all 12

Trending Articles