I am porting an iOS app to OS X. I was looking at using the Apple sample code "AnimatedTableView" as a starting point, but was surprised to find it has no NSApplicationDelegate. On iOS, I generally create objects programmatically, in applicationDidFinishLaunching and am trying to figure out how to do that on OS X, unless I should not.
The MainMenu.xib for AnimatedTableView contains a "ContentController" object which references one of their controller classes. It looks like the "wakeFromNib" method of this class is where the action starts. Is it correct that any objects you add to MainMenu.xib are automatically instantiated on application launch? So, I could just put a master controller class in the MainMenu.xib and begin creating other objects programatically from there? Or, to stick with my iOS pattern, I could replace the controller object in the MainMenu.xib with an NSApplicationDelegate object and have it programmatically create the master controller object?
Is that correct? I try to avoid IB as much as possible, and obviously am missing some basic understandings.
Is it correct that any objects you add to MainMenu.xib are automatically instantiated on application launch?
It would be more correct to say that a Cocoa application that's set up to use .xib files instead of storyboards will automatically load the .xib file specified as the main nib file in the application's Info.plist file. But yes, a .xib-based app will typically be set up to load MainMenu.xib at launch.
So, I could just put a master controller class in the MainMenu.xib and begin creating other objects programatically from there?
Sure, that's one approach that works.
Or, to stick with my iOS pattern, I could replace the controller object in the MainMenu.xib with an NSApplicationDelegate object and have it programmatically create the master controller object?
There should already be an application delegate object in the project. What's more, there's an app delegate proxy in the main .xib file, so you can add outlets to the app delegate and connect them to objects in the main .xib file. If you want to create the "master controller" object in the app delegate, you can certainly do that.