views:

566

answers:

2

Could someone explain the kinds of placeholder objects that may appear in the Interface Builder document window?

The kinds of placeholders that I know exist are: File's owner, First Responder and App Delegate

Links:

+3  A: 

I copied this from apple's Developer website on Interface Builder, Hope this helps.

Basically in my own words the place holders hold everything in your program and they consist of everything that the user see's, like a UIView or a UIImageView, something along those lines

Choose Appropriate Controller Objects

In Cocoa and Cocoa Touch nib files, the File’s Owner placeholder object provides the key link between your application and the objects in the nib file. When you load the nib file, you must provide the nib-loading routine with a pointer to the object that should become the File’s Owner. As part of the loading process, the nib-loading code automatically recreates any connections between the object you specify and the nib file objects that have connections to the File’s Owner.

As you design the architecture of your application, it is important to consider which objects you want to manage your nib files. The presence of only one File’s Owner placeholder object is not without good reason. It is usually best to have a single object coordinate the loading and management of a nib file and its contents. This single point of contact provides the desired barrier between your application’s data model and the visual elements used to present that data model and is at the heart of model-view-controller design.

Beyond the File’s Owner object, you can create additional controller objects directly in your nib file to manage subsets of the nib file. Using multiple controllers in this way lets you compartmentalize the window’s behavior into more manageable chunks. For example, if your window has multiple panes of disparate information, you could create separate controller objects to manage each pane. Each controller would continue to go through the File’s Owner to obtain additional information.

In iPhone applications, it is also possible to include placeholder objects besides File’s Owner in your nib file. These additional placeholder objects are almost always used to represent navigation controllers and other view controllers already in use by your application. The presence of these additional placeholder objects does not diminish the role of File’s Owner though. The File’s Owner object is still responsible for coordinating the overall behavior of the nib file’s contents.

Jaba
Thanks for the explanation. It is worth knowing that inside interface builder the class of File's Owner can be set from the information tab of the inspector.
Casebash
I suppose now that I found some answers to other parts on other questions, this answer seems to answer the only remaining bit.
Casebash
You are welcome
Jaba
+1  A: 

I think I provided a thorough answer to this here in a response to this question.

Also, I would call the App Delegate a placeholder. A placeholder is an object that's available in a NIB file for making connections to and from, but isn't instantiated when that file is loaded. So, when you have an orange cube in the MainWindow.xib file with the custom class set to "MyAppDelegate", that causes an instance of "MyAppDelegate" to be instantiated when the NIB is loaded. As a counter example, the file's owner of MainWindow.xib is typically "MyApplication", and an instance of MyApplication won't be instantiated when the NIB is loaded, it's already alloced and initted, and is doing the loading. So, the file's owner is a placeholder for an object that already exists, and the app delegate typically isn't.

Jon Hess