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

Is it possible to pass an object to a NIB


  • Subject: Is it possible to pass an object to a NIB
  • From: DeNigris Sean <email@hidden>
  • Date: Fri, 4 Dec 2009 22:47:16 -0500

Hi list!

I'm writing a RubyCocoa app, but my question is on the Cocoa API...

I'm trying to unit test a view class.  As it is very thin (just delegates all work to the controller), all I want to check is that my connections (e.g. outlets and actions) are hooked up correctly.

I've been trying to:
1. Create an instance of my class
2. use NSBundle::loadNibFile: externalNameTable: withZone: to load the nib
3. check the connections

The docs for loadNibFile (http://developer.apple.com/mac/library/documentation/Cocoa/Reference/ApplicationKit/Classes/NSBundle_AppKitAdditions/Reference/Reference.html) seem to suggest that you can pass objects in:
"A name table whose keys identify objects associated with your program or the nib file. The newly unarchived objects from the nib file use this table to connect to objects in your program."

But I can't get it to work after hours!

This code is in ruby, but it's just bridged to the corresponding Cocoa calls:
	view = MyView.new # subclass of NSWindowController
	NSApplication.sharedApplication
	top_level = [] # I've tried passing everything I could think of here:
				- view # the object instance
				- "My View" => view # NSDictionary with key object name in IB and value object instance
				- MyView => view # NSDictionary with class name / object entry

	# I Also tried passing the object, and object-containing dictionaries below
	# e.g. dictionaryWithObjects_forKeys [NSApp, top_level, view], [NSNibOwner, NSNibTopLevelObjects, "My View"]
	context = NSDictionary::dictionaryWithObjects_forKeys [NSApp, top_level], [NSNibOwner, NSNibTopLevelObjects]

	NibPath = ".../RandomAppRuby.app/Contents/Resources/English.lproj/MainMenu.nib"

	OSX::NSBundle::loadNibFile_externalNameTable_withZone NibPath, context, NSApp.zone

Thanks in advance for any guidance!

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: Ken Thomases <email@hidden>
    • Re: Is it possible to pass an object to a NIB
      • From: Chris Hanson <email@hidden>
  • Prev by Date: Re: Getting Text Colors Right for Derived NSTextFieldCell under Various Conditions
  • Next by Date: Re: Getting Text Colors Right for Derived NSTextFieldCell under Various Conditions
  • Previous by thread: Re: NSToolbar problem in 10.6
  • Next by thread: Re: Is it possible to pass an object to a NIB
  • Index(es):
    • Date
    • Thread