Mark Cowan
Mark Cowan

Reputation: 93

What is the purpose of the Application placeholder in a MainMenu.xib file in Interface Builder?

Application placeholder (highlighted)

Apple’s developer documentation on Nib Files in Interface Builder mentions the Application placeholder (highlighted in the picture above) but doesn’t explain its purpose or when it should be used. The article explains the other two placeholders—File’s Owner and First Responder—fairly well.

I would appreciate any information on the Application placeholder, with links to any documentation that I may have missed.

Also, in the Identity Inspector, why is the Application placeholder of type NSObject instead of, for example, NSApplication?

Upvotes: 3

Views: 919

Answers (1)

Willeke
Willeke

Reputation: 15589

From the documentation of Interface Builder 3.2.6 (copyright 1999-2010):

In Cocoa nib files, the Application placeholder object gives you a way to connect the outlets of your application's shared NSApplication object to custom objects in your nib file. The default application object has outlets for its delegate object and, in Cocoa applications, the application menu bar. If you define a custom subclass of NSApplication, you can connect any additional outlets and actions defined in your subclass.

In an old MainMenu.nib file from 2009, the delegate is connected to the Application placeholder instead of the file's owner. In a XIB file from 2012, the Application placeholder isn't class NSObject. Nowadays the only use I can think of is binding something to Application.delegate.someProperty.

Upvotes: 1

Related Questions