In Mono I have a simple NSWindow with Controller on it I drop a NSSplitView and a NSButton.
If I try to access the NSSplitView out of the Contstructor or Initialize()
Method I get a nullReferenceException. Instead if I try to access the NSSplitView from a ButtonClicked Method, it works.
Well, it seems that the Framework creates the GUI Components after the controller's Construtor is called. But where should I put my code to configure GUI Components if not in the Constructor?
Thanks in advance. Johannes
You should use the
AwakeFromNib
method in your controller class. It is called once all the objects have been loaded and properly connected.You should use
for configuring your view because that's the method which is called when the view just loaded, not when you instantiated the controller. If you configure your view in
AwakeFromNib()
you'll force the instantiation of your view whereas you maybe don't need them now. Indeed, when you create a controller the view are not created until someone try to access viewController.View.