On Apr 15, 2009, at 2:08 PM, Sidney San Martín wrote:

I want to hook up actions and bindings in a nib (loaded with
+[NSBundle loadNibNamed:owner:]) to an object other than File's Owner
(one which will already exist when the nib is loaded). Can I create a
reference to a second object in Interface Builder without causing it
to be instantiated and hook it up at runtime, in the style of File's
Owner?

Or, am I going about this the wrong way? I have an NSStatusItem which
started out managed by my application controller. It's getting
complicated, and I was planning to move it to its own nib and move
control over it to a new object. Problem is, it still needs actions
and bindings in the application controller. I could always instantiate
my menu controller in the nib and make it's owner the app controller,
but the above feels much cleaner. Is there an option I'm not thinking
of?

If it's reasonable to split your NIB in two, and have a second NIB file that can be directly loaded and wired to the object that will control it, that approach makes more sense. NIB files are easiest to manage when they are one contained group of functionality, managed by a single controller - the file's owner. If you find yourself wanting to have two external objects (File's owners) it's probably best to use two NIB's. Once you factor the NIB files apart, there's nothing stopping you from reconstituting the results of loading them into one interface.

If you decide to stick with one NIB, the most straight forward thing to do would be to connect your controls to the file's owner, and have it associate them with the external controller after loading the NIB.

Jon Hess

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/jhess%40apple.com

This email sent to jh...@apple.com

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to