• 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: Canonical way of loading compound UI components from a NIB into some other UI?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Canonical way of loading compound UI components from a NIB into some other UI?


  • Subject: Re: Canonical way of loading compound UI components from a NIB into some other UI?
  • From: Joshua Emmons <email@hidden>
  • Date: Wed, 5 Dec 2007 17:56:18 -0600

So, lets say I have a my compound control hierarchy, consisting of a scroll view at the top, which then contains a number of other views. These are all stored in a Nib called ScrollingControls.nib. Now, in my main Nib, I might have a NSWindow and I wish to place a custom view within this window that will define the location of the root view in my ScrollingControls hierarchy.

I'm just one guy, so I wouldn't call it canonical, but when I've had to do this, I drop a NSScrollView on my window and make an outlet for it in my window controller. Then, when the time is right (usually - awakeFromNib for me), I use said outlet to replace the scroll view's document view.


In this example, my nib with all the controls in it has an NSView at the top level, not an NSScrollView. I find this allows for greater flexibility and reusability as 1) I might not always want my controls to scroll, and 2) the scroll view is used to having its document view swapped out on it and has machinery in place to deal with this. But YMMV.

Finally, if your nib of controls is even slightly complex and you're targeting 10.5, read up on NSViewController. It's like a window controller, only for views. It can really help organizing the loading of nibs, memory management, etc. Also, it has one of those representedObject bindings which again enhances flexibility and reusability. I find it ups the "elegance factor" of doing this sort of thing by at least 2 points. ;-)

Cheers,
-Joshua Emmons
_______________________________________________

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


  • Follow-Ups:
    • Re: Canonical way of loading compound UI components from a NIB into some other UI?
      • From: Luke Evans <email@hidden>
References: 
 >Canonical way of loading compound UI components from a NIB into some other UI? (From: Luke Evans <email@hidden>)

  • Prev by Date: Re: [CA] Create a "A la FrontRow" Button
  • Next by Date: Re: CIContext to NSImage
  • Previous by thread: Re: Canonical way of loading compound UI components from a NIB into some other UI?
  • Next by thread: Re: Canonical way of loading compound UI components from a NIB into some other UI?
  • Index(es):
    • Date
    • Thread