But, just exactly HOW does the actual documentWindow object get passed so that
someMethod can look at one of its properties?

This question is oriented to "behind the scenes"
   
  For the current version of Interface Builder, see 
  - (void)connectOutlet:(NSString 
*)outletofSourceObject:(id)sourcetoDestinationObject:(id)destination
   
  of the IBDocument class in the InterfaceBuilderKit framework.
   
  In the current version of Interface Builder, the precise mechanism for 
storing connection information is not documented and therefore considered an 
implementation detail.  However, in previous versions of Interface Builder, it 
worked like the following:
   
  There is/was a class called IBConnector which looked something like this
   
  @interface IBConnector : NSObject <NSCoding>
  {
     id              source;
     NSString   *outletName;
     id              destination;
  }
   
  - (void)setSource:(id)anObject;
  - (void)setOutletName:(NSString *)aName;
  - (void)setDestination:(id)anObject;
   
  - (void)connect;
   
  @end
   
  When you drag a connection in IB, a new instance of IBConnector is created, 
initialized with a source, outlet name, and destination accordingly, and 
archived into the .nib file.
   
  When the nib file is tested in IB or loaded into your application at 
run-time, the IBConnector instances are unarchived just like every other object 
in the nib.  Once unarchived, each IBConnector instance's source and 
destination instance variables are restored to a reference to the corresponding 
unarchived objects. [That is just how archiving and unarchiving graphs of 
objects works.  Read up on archiving for details].
   
  As part of the nib loading process but before -awakFromNib is sent to any 
objects unarchived from the nib, the connect message is sent to each unarchived 
IBConnection instance.
   
  The -connect method of IBConnector is implemented something like this
  - (void)connect
  {
     Ivar   ivar = class_getInstanceVariable([source class], [outletName 
UTF8String]);
     object_setIvar(source , ivar, destination);
  }  
   
  See 
http://developer.apple.com/documentation/Cocoa/Reference/ObjCRuntimeRef/Reference/reference.html
 for information about class_getInstanceVariable() and object_setIvar(). The 
source code for the runtime is also available.
   
  Once the connections are all made, the IBConnector instances are no longer 
needed and may be deallocated.
   
  Then -awakeFromNib is called for every object unarchived from the nib and 
incidentally also the "File's Owner" object.  Because the connections were all 
restored before -awakeFromNib, it is safe to use the connections in your 
implementation of -awakeFromNib.
   
  Does that answer you "behind the scenes" question ?
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to