I am using storyboard instantiateViewControllerWithIdentifier: and I\'m noticing that all the IBOutlets I have wired up are still nil. However, the
People gave solution of how to get the view loaded (some of which you should never use (loadView()) so here is a way to check whether your view is already loaded
I ran into the problem because I had a property with a didSet observer to update the UI which obviously doesn't work if the outlets are not yet set, so here is some example code how to work around it:
var name: String? {
didSet {
updateNameLabel()
}
}
override func viewDidLoad() {
super.viewDidLoad()
updateNameLabel()
}
func updateRoomLabel() {
guard isViewLoaded() else {
return
}
[...]
}
So now when you display the outlets get updated but also every time you update the property