Re: Re-using a custom view
Re: Re-using a custom view
- Subject: Re: Re-using a custom view
- From: Shawn Erickson <email@hidden>
- Date: Fri, 08 Dec 2006 10:54:18 -0800
On Dec 8, 2006, at 10:39 AM, Sanford Selznick wrote:
Hello,
How can I create, say, a Nib with one NSView in it with a few
buttons and a field, and then install that NSView into other
windows? I'd like to re-use the code and view.
What's the easiest way? The solutions I'm finding out there are
kind of complicated. I'm looking for something nice and simple. :-)
1) Put that view into a nib.
2) Define a "controller" class and make that class the owner of the nib.
3) Add an outlet from the "controller" class (files owner) to the
view in the nib.
4) Have the "controller" class use NSNib to instantiate new instances
of the nib (make sure to correctly manage top-level objects of the nib).
5) Each time you need the view instantiate a new "controller" class
and do what you want with the view it has a reference to.
That is one way out of many...
-Shawn
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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