File's Owner is not a real object in the xib file. It is a proxy object. It represents the object that will become the xib's owner when it is loaded. First Responder and App Delegate are proxies also. The first responder is the object currently on top of the responder chain. When the state of the application changes, another object might be the first responder. You use this proxy object to connect things like the File->Save menu to whatever object is responsible handling it at any given time.
The App Delegate is an actual object. It springs to live when the xib is loaded. As you can see in Interface Builder, it is connected to the delegate outlet of file's owner. The Application loads the MainWindow.xib, it is therefor the file's owner.
Other xib file are usually loaded through a delegate object. That delegate object is the file's owner. But the delegate itself is instantiated from code. It is not loaded from the xib. That's why it is not shown in Interface Builder.
xib files contain actual serialized objects. File's Owner and First Responder are exceptions. They represent some other, already existing object.
File's Owner (often a UIViewDelgate in non MainWindow.xib files) is the chicken. The xib is the egg. The chicken itself is not contained in the egg.
A bit long. Hope it helps.
First, placeholder is a better word than proxy here.
Normally when you have an object in a NIB/XIB file it means that loading the NIB file will create that instance. The placeholder objects are objects that will already exist when the NIB file is loaded, and they appear inside of the NIB so that you can make connections between the objects that will be created by loading the NIB and the objects that already exist.
The file's owner, first responder and application are all placeholders.
The file's owner is placeholder for the object that will load the nib. All of the NIB loading methods take an 'owner' parameter. When you make a connection with the File's owner, when it's established at runtime, it will be connected to the owner object passed in to the nib loading method. Many UIKit and AppKit classes invoke the nib loading methods for you. NSApplication
, NSViewController
, NSWindowController
, UIApplication
, and UIViewController
all load NIB files on your behalf. When they do that they pass self as the owner parameter to the nib loading methods. That's why when you use a view controller or a window controller you set the file's owner to your subclass and make most of the connections between your views and the file's owner.
The NSApplication
instance is a simple placeholder for [NSApplication sharedApplication]
. That's a global singleton and the icon in Interface Builder represents that global singleton. Loading the NIB file does not create a second NSApplication
instance. By contrast, when a NIB file contains a window, if you load it a dozen times, you'll have a dozen window instances, but still one NSApplication
instance.
The first responder is unique. Connecting an action to the first responder means that when the action is fired, it should dynamically be sent to the responder chain. The responder chain typically starts with the focused view, and continues up through the view hierarchy and includes some controllers and delegates. Each object in the chain gets a shot at handling the action. Menu items work great with the responder chain. If you had a menu item for "Make Bold" that is supposed to make the currently selected text bold, you might start by hooking that up to an NSApplication
subclass, but then you'd have to know all of the situations that "Make Bold" applies, and how to handle them. A text view and an editable web view would probably need different code to handle "make bold" and bottling this all up in one object would get quite complex and wouldn't be very extensible. Instead you could connect the "Make Bold" menu item's action up to a makeBold:
action on the First Responder. This would mean that when the menu item was selected, the focused object, or one of its parents that responded to makeBold:
, would get the makeBold:
message. Now many classes can implement a makeBold:
method and respond to this menu item when they're in focus.
Best Answer
I copied this from Apple's developer website on Interface Builder, Hope this helps.
Basically in my own words the placeholders hold everything in your program and they consist of everything that the user sees, like a
UIView
or aUIImageView
, something along those lines