• 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: Sanford Selznick <email@hidden>
  • Date: Fri, 8 Dec 2006 12:23:09 -0700

At 10:54 AM -0800 12/8/06, Shawn Erickson wrote:
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.

Wonderful. Thank you very much.

Is 5 as simple as calling NSView's addSubView on the "host" view? Will that fix up field tab ordering and everything?

Thanks,
  Sanford
_______________________________________________

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: Sean Murphy <email@hidden>
References: 
 >Re-using a custom view (From: Sanford Selznick <email@hidden>)
 >Re: Re-using a custom view (From: Shawn Erickson <email@hidden>)

  • Prev by Date: Re: Re-using a custom view
  • Next by Date: Launching a external application from my application
  • Previous by thread: Re: Re-using a custom view
  • Next by thread: Re: Re-using a custom view
  • Index(es):
    • Date
    • Thread