IBOutlet is not installed in Cocoa MVC project

I can't seem to use IBOutlet or some other subtlety of NIB files that is causing me problems - any help would be much appreciated (feel free to suggest an alternative way to accomplish what I want).

I have a View object and a Controller object. Both are in the NIB. The controller initiator is also called when the NIB is loaded and the view is initialized in the "awakeFromNib" callback. I need a way to connect these two objects - specifically, include a View object to call functions on the controller.

Based on the documentation online, the way to connect to it is to define the IBOutlet in the view and connect it to the controller in the interface builder. So I created

IBOutlet Controller* _controller;

      

in the View interface and graphically connected it to the Controller object in the Interface Builder, making a connection to the view on the controller and assigning the controller output to the controller (blue Generic Object field in Interface Builder).

At runtime, _controller is always _nil. I have verified that the initialization of the Controller was indeed called.

Is there something obvious I'm missing this? Any easy way to connect these two? Since they are both created by NIB, I don't have a common object that has a pointer to both.

+1


a source to share


1 answer


Try looking IBOutlet

in viewDidLoad

instad.



awakeFromNib

Not all IBOutlets

are filled when called (although the documentation seems to imply it).

0


a source







All Articles