Create instance of class in nib file

2019-09-04 15:03发布

问题:

Im going through Apple's OSX Cocoa (Your First Mac Application) tutorial and am up to refactoring the app delegate. I have created my own controller class.

I don't understand how to "Create an instance of the controller class in the nib file". I'm using Xcode 4.

回答1:

Drag an 'Object' from the 'Object Library' in the right pane onto your nib. Next, select the object that you dragged into the nib, and then select the identity inspector (third icon from the left in the top right pane). From these, you can set a custom class. Set the class to be the custom controller that you have created. This will be created for you when the nib is initialized. You can then connect this to an IBOutlet in your AppDelegate (for that custom class).



回答2:

I think what you want is on the inspector, click the third tab, and for the "Custom Class", select your view controller.



标签: xcode xcode4