Re: Swapping IB-created views and keeping IBOutlets hooked up
Re: Swapping IB-created views and keeping IBOutlets hooked up
- Subject: Re: Swapping IB-created views and keeping IBOutlets hooked up
- From: Alex Kac <email@hidden>
- Date: Tue, 16 Sep 2008 23:45:09 -0500
Perfect - I appreciate it.
On Sep 16, 2008, at 10:11 PM, Jonathan Hess wrote:
Hey Alex -
If your controller is the File's Owner, and in your NIB there is a
connection connecting the the File's Owner's 'myButton' outlet to a
button, then when you load the nib, the controller's myButton
instance variable will be connected to the button in the nib. So
far, everything I've described is normal.
Now, if you just load a second NIB file with NSNib using your
controller as the File's Owner, and this second NIB has a different
connection connecting the the File's Owner's 'myButton' outlet to a
button, then when you load this second nib, your controller's
myButton outlet will be updated to point to the my button in the
second nib.
If you wanted to switch back to the first layout, you could just
load the original NIB again.
If your controller is an NSWindowController or an NSViewController,
you probably want to be working with two secondary NIB's since the
window or view controller will be expecting the NIB they load to
setup their top level window or view. In each of your secondary
nibs, you could load a whole UI wrapped in a view that you place
into your NSWindowController or NSViewController managed window/view.
Good Luck -
Jon Hess
On Sep 16, 2008, at 3:33 PM, Alex Kac wrote:
I have two views that are different layouts of the same UI loaded
by a NSViewController. Now lets say that I have an IBOutlet to an
NSButton* button1 that is present in both views. I want to swap one
view out for the other and when I do so have the IBOutlet for
button1 swap to the button1 defined in the second view in another
NIB.
So for example, the viewcontroller inits with View A. button1 is
assigned to the NSButton in View A. I then swap that view to View B
which also have a button1. View B is in a different NIB. So I want
button1 to now point to View B. Is this something that can be done
automatically?
One way I was thinking of doing this was as follows:
IBOutlet NSButton* button1_viewA;
IBOutlet NSButton* button1_viewB;
IBOutlet NSButton* button1;
and then point button1 to whatever is the currently displayed view.
That's fine and doable, but before I do that I wanted to know if
there was a better way, a more manageable way.
Thanks!
Alex Kac - President and Founder
Web Information Solutions, Inc.
"If at first you don't succeed, skydiving is not for you."
-- Francis Roberts
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden
Alex Kac - President and Founder
Web Information Solutions, Inc.
"You cannot build a reputation on what you intend to do."
-- Liz Smith
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden