• 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: Is it possible to pass an object to a NIB
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is it possible to pass an object to a NIB


  • Subject: Re: Is it possible to pass an object to a NIB
  • From: DeNigris Sean <email@hidden>
  • Date: Sat, 5 Dec 2009 18:46:40 -0500

> Really, the external name table is for referring to objects in nibs, rather than pushing objects into nibs.
Thanks.  That's what I wanted to know - I thought the docs suggested maybe you could pass objects in (other than owner)

> Furthermore, from your further description it sounds like what you’re referring to as a “view” is actually a subclass of NSWindowController; it knows how to load a nib file already, so you should just leverage that rather than try to do it all yourself by hand.
Thanks again.  It's an "ultra-thin gui" a-la Dave Astels' TDD: A Practical Guide (originally Mike Feathers' Humble dialog).  There is another controller class that handles all the logic.  This class just delegates the actions and outlets from Cocoa, so from my app's perspective, it's a view, but from cocoa's perspective, it's a controller.  It think it should be just an NSObject (that's what I've seen in all the books and there's only one window in my app).  I made it an NSWindowController in the process of trying to get it to load the nib (which is only for testing) and forgot to set it back.  Is there a reason to keep it an NSWindowController?

I ended up with the following that loaded the nib successfully in the test:
NSApplication.sharedApplication
top_level = []
context = NSDictionary::dictionaryWithObjects_forKeys [NSApp, top_level], [NSNibOwner, NSNibTopLevelObjects]

@@NibPath = "/path/to/MainMenu.nib"
OSX::NSBundle::loadNibFile_externalNameTable_withZone @@NibPath, context, NSApp.zone

objects = context['NSTopLevelObjects']
view = objects.find { |obj| obj.class == object_type }

Sean DeNigris
email@hidden

_______________________________________________

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: Is it possible to pass an object to a NIB
      • From: Chris Hanson <email@hidden>
References: 
 >Is it possible to pass an object to a NIB (From: DeNigris Sean <email@hidden>)
 >Re: Is it possible to pass an object to a NIB (From: Chris Hanson <email@hidden>)

  • Prev by Date: Re: NSOutlineView expand-by-default with NSTreeController
  • Next by Date: Re: Is it possible to pass an object to a NIB
  • Previous by thread: Re: Is it possible to pass an object to a NIB
  • Next by thread: Re: Is it possible to pass an object to a NIB
  • Index(es):
    • Date
    • Thread