views:

3091

answers:

1

When I make a sample app (ie, start out with a tab bar application or something), in my MainWindow.xib file, I see 5 items listed -- File's Owner, First Responder, App Delegate, Window, and Tab Bar Controller.

If I make another .xib file, and make a delegate for it, and set that File's Owner to my new delegate that I just made, I do NOT see "NewDelegateFile" in the list of...objects(?) for that .xib.

This doesn't make sense to me, and I think is a huge part of why I'm not catching on all that quickly to iPhone development.

Does anyone care to take the time to explain that little peculiarity to me?

+12  A: 

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.

rincewind
I wasn't ignoring this answer. It just took me days of playing around and reading over and over again to understand it. And I think I do, now. Thanks so much. It's just a little inconsistent to how my mind thinks it should be, but I'll keep making my head try to think this way. Thanks so much for your response.
Matt Dawdy