What programming experience do you have?  Perhaps I can explain File's Owner in 
terms of some other framework you already know ?
  You use the File’s Owner “proxy” in each nib file to enable connections or 
key paths to objects that are not instantiated within that nib file.  Interface 
Builder needs an icon for you to drag such connections to and from.  File’s 
Owner is just such an icon.  First Responder is another such Icon.  Any 
connections or key paths that involve the File’s Owner icon will be established 
with whatever object is specified as the “owner” when the nib file is loaded 
via + loadNibNamed:owner:.   The MainMenu.nib file is loaded automatically by 
the framework by calling code similar to [NSBundle loadNibNamed:@”MainMenu” 
owner:NSApp];  Does that line of code mean anything to you ?
  Nib files can be loaded at any time while an application is running, and the 
same nib file can be loaded multiple times creating new copies of all objects 
within the nib each time.  Can you see how it is useful to be able to make 
connections to objects that are not instantiated within the same nib file ?  
Consider how NSDocument loads nib files that define the objects representing 
each document instance.
  @implementation MYDocument : NSDocument
  {
     IBOutlet NSTextField   *someTextFiledInMyAssocoatedNibFile;
  }
   
  - (NSString *)windowNibName
  {
     Return @”MYNibFile”;
  }
  @end
   
  At some point, you will create a MyDocument instance and as part of its 
initialization it will execute a line of code like the following:
  [NSBundle loadNibNamed:[self windowNibName] owner:self];
  Because the MYDocument instance is the owner specified when the nib is 
loaded, any connection made within the nib to the 
someTextFiledInMyAssocoatedNibFile outlet will be connected to the instance of 
MYDocument that loaded the nib file.
  When you open a second document, it will also call [NSBundle 
loadNibNamed:[self windowNibName] owner:self]; except the “self” refers to the 
second instance of MYDocument.  Loading the nib file twice creates two copies 
of every object within the nib file, but the connections made to File’s Owner 
within the nib file are established to the two different instances of 
MYDocument.
   
  P.S.
  You say "I don't know what object loaded my nib, so that does not help me" 
and then immediately quote the documentation which says "In MainMenu.nib, this 
is the application instance, which is a shared singleton instance of 
NSApplication which is also set to the global variable NSApp."  The 
documentation explicitly  tells you that in the case of the MianMenu.nib file, 
the File’s Owner is a proxy for an instance of the NSApplication class.
  You then say "how all applications can share this is beyond me".  This 
indicates to me that you don't know what a Singleton is and don’t know what a 
Proxy is and don't know what a global variable is and don't know that with Unix 
(e.g. Mac OS X) applications do not generally share global variables.
  It's no wonder you are struggling with Cocoa.  You are apparently not a C 
programmer, not aware of common object oriented patterns like the Singleton, 
and not familiar with Unix.  In my opinion, C programming, pattern awareness, 
and basic operating system familiarity are all prerequisites to learning Cocoa.
_______________________________________________

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