Reputation: 61538
I come from an iPhone application development background. I am trying to understand how the application initialization phase works in an OS X application. The one thing I find puzzling is that when you initially created an application in Xcode 4.5.1 it gives you a single XIB file with both a File's Owner
object and an Application
object.
Both seems to have the similar if not same set of outlets and interfaces. So I was wondering:
NSApplication
instances during NSApplicationMain()
?File's Owner
of this XIB's contents?Upvotes: 2
Views: 316
Reputation: 9198
NSApplicationMain is a black-box, you shouldn't care exactly what it does (and i don't know exactly, but it does many different things) but we can be sure that either directly or indirectly it reads the app bundle's info.plist, finds a name for the Principle Class and name for the nib containing the main-menu, creates an instance of the Principle Class (NSApplication or a subclass) which, in turn un-serializes the main-menu.
All nibs have a placeholder for the App's NSApplication instance and the nib's 'File's Owner' (the object that un-serialized the nib).
As the NSApplication instance un-serializes the main-menu nib, in this case the Application and File's Owner placeholders just happen to be the same object. Whichever you connect an Outlet to, you are connecting to the same object.
Upvotes: 1