• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Re-using a custom view
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Re-using a custom view
      • From: Sanford Selznick <email@hidden>
References: 
 >Re-using a custom view (From: Sanford Selznick <email@hidden>)

  • Prev by Date: Re-using a custom view
  • Next by Date: Re: Re-using a custom view
  • Previous by thread: Re-using a custom view
  • Next by thread: Re: Re-using a custom view
  • Index(es):
    • Date
    • Thread