Re: Dynamically loading a part of a Window in Cocoa
Re: Dynamically loading a part of a Window in Cocoa
- Subject: Re: Dynamically loading a part of a Window in Cocoa
- From: Quincey Morris <email@hidden>
- Date: Wed, 1 Jul 2009 00:54:14 -0700
On Jul 1, 2009, at 00:28, Thomas Davie wrote:
On 1 Jul 2009, at 09:21, Debajit Adhikary wrote:
(Is it enough to place a generic NSView there and add a subview
each time?
I'm fairly new to Cocoa, so any pointers are welcome)
Yes -- at least that's what I do, if I'm doin it rong, hopefully
someone will tell me :)
As others have said, using a tabless NSTabView is generally easier,
though if you need to actually release the view which isn't currently
in the window, this technique doesn't do that. (Typically you don't
need to release it.)
But if you are going to replace the subview "manually", the tricky
part is to make sure that its nib objects are released properly, which
means carefully studying the NSNib nib-loading and ownership document
to decide if there's anything you need to do.
In Leopard (and the iPhone, I guess), the easier way is to use a
NSViewController, because it handles nib object ownership issues for
you. The view controller loads the nib for you, though you still need
to swap the subviews manually.
The other advantage of NSViewController is that if your subviews each
need some controller logic, it modularizes your code if you can move
it to the NSViewController, instead of having to dump it all in the
window controller.
_______________________________________________
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