• 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: Toplevel Objects in NIB files
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Toplevel Objects in NIB files


  • Subject: Re: Toplevel Objects in NIB files
  • From: Sherm Pendley <email@hidden>
  • Date: Tue, 2 Apr 2002 20:26:52 -0500

On Tuesday, April 2, 2002, at 07:32 PM, Nat! wrote:

I asked this before, but under a different subject line, so maybe it didn't get any attention :)

What I would _really_ like to know is how NSWindowController learns to know all top level objects in its associate NIBs. This is a trick I would like to do myself sometimes.

After the NIB is loaded and the objects in it deserialized, for each outlet, a corresponding set*: method is looked for in the NIB's owner, and if it's found, called.

For example, if you've created and connected an outlet named "myButton" in IB, the method "setMyButton:" will be called when the NIB is loaded, with a pointer to the object loaded from the NIB.

The Objective-C runtime will generate accessor methods automagically. So, if no "setMyButton:" method is defined, but a "myButton" instance variable exists, the value passed to the method call is assigned to the instance variable. Similarly, if a "myButton" is called, the value of the instance variable is returned.

FWIW, I don't recall seeing any really good documentation about this - and I looked hard, because it's very important for supporting dynamically-loaded NIBs within a language bridge. I figured it out for CamelBones by coding my proxy class to report the name of each method asked for with "respondsToSelector:", and then noticed that a call to "setWhatever:" got generated for each outlet I wired up in my NIBs.

I *think* that this happens in the establishConnection: method of the NSNibOutletConnector class - but the documentation only says that this method establishes connections, without saying anything about how they're established.

Hope this helps!

sherm--
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Toplevel Objects in NIB files
      • From: Vince DeMarco <email@hidden>
    • Re: Toplevel Objects in NIB files
      • From: Graeme Hiebert <email@hidden>
    • Re: Toplevel Objects in NIB files
      • From: Nicholas Riley <email@hidden>
References: 
 >Toplevel Objects in NIB files (From: Nat! <email@hidden>)

  • Prev by Date: Re: Malloc()
  • Next by Date: Re: How to get objects to not be encoded with NSArchiver
  • Previous by thread: Toplevel Objects in NIB files
  • Next by thread: Re: Toplevel Objects in NIB files
  • Index(es):
    • Date
    • Thread