I have seen code where IBOutlets modify their properties using a didSet like so..
@IBOutlet private weak var tableView: UITableView! {
didSet {
tableView.dataSource = self
tableView.delegate = self
}
}
Is this considered good practice, or should we create a configure method in viewDidLoad?
Actually didSet here
outer part
didSet {
// refresh
}
makes more sense if the outer var you observe is rapidly changing / real time so you need to react to this change , but for the current case which is the table is set only once from IB inner init using didSet has no bounce over putting the code inside viewDidLoad
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With