• 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: File's Owner
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: File's Owner


  • Subject: Re: File's Owner
  • From: Quincey Morris <email@hidden>
  • Date: Mon, 26 May 2008 10:49:03 -0700


On May 26, 2008, at 00:54, Uli Kusterer wrote:

This object must exist *before* the NIB is loaded, so it can not be created by the NIB (can't be a blue box you drag out of the Library), and can not be in the NIB. However, often objects inside the NIB want to talk to the owner, so they added the File's Owner icon, which stands in for whatever object loads the NIB. Since NIBs are kinda generic, and don't know for sure who loads them until runtime, IB uses whatever class you specify as the class identity for File's Owner to decide what connections to offer you.

Except that in trying to reduce your explanations to essentials, I think you've strayed into inaccuracy. File's Owner isn't the object that loaded the nib, it's the object that the object that loaded the nib *says* is the owner.


With regard to this thread in general, and *not* related to your explanation in particular, I'd like to suggest that there are two major barriers to comprehensibility for someone trying to understand File's Owner.

-- First, although it's *called* "File's Owner", the concept isn't essentially about files or ownership. It's about connection (specifically, connecting an object defined outside the nib to the object graph defined inside the nib). Yes, in the usual cases (NSApplication, NSDocument, NSWindowController and NSViewController) there are some frameworks-provided ownership-like qualities when objects of those classes are used as File's Owner, but that's more convenience than essential-ness.

Note, for example, in a document-based application created using the Xcode template, File's Owner of MyDocument.nib (which in spite of the name is essentially a window nib file) is a NSDocument, although (I assume, though I could be wrong) that the nib is actually loaded by the NSWindowController created by the NSDocument. And since the lifetimes of the objects loaded from the nib are controlled by the NSWindowController, it could stake a claim to being the owner of those objects, though not File's Owner. The NSDocument, though File's Owner, doesn't really own anything, in any useful sense.

-- Second, saying that "File's Owner is the object specified as the owner when the nib is loaded" (as the documentation does) isn't very helpful to someone trying to come to grips with the concept, since unless your application becomes large or complex enough to need specialized (or highly factored) nib files, you're unlikely to *load* a nib yourself, in the sense of writing an invocation of 'loadNibNamed:owner:'.

For main menu nibs (using NSApplication), window nibs (using NSDocument or NSWindowController) and view nibs (using NSViewController), you don't specify File's Owner, you use the File's Owner that the controller class determines on your behalf. So, a newbie's first exposure to File's Owner suggests that there's a right answer to what File's Owner needs to be, but the documentation (along with quite a number of the explanations in this thread) insists that File's Owner can be whatever you want it to be. Unless you clear up that *apparent* contradiction first, you can lucidly explain File's Owner till you're blue in the face without shedding any light whatsoever.
_______________________________________________


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: File's Owner
      • From: Andreas Mayer <email@hidden>
    • Re: File's Owner
      • From: dream cat7 <email@hidden>
References: 
 >File's Owner (From: Johnny Lundy <email@hidden>)
 >Re: File's Owner (From: Uli Kusterer <email@hidden>)

  • Prev by Date: NSFileManager's errors in 10.5, where are they documented?
  • Next by Date: Re: How hard is it to learn Cocoa - Survey?
  • Previous by thread: Re: File's Owner
  • Next by thread: Re: File's Owner
  • Index(es):
    • Date
    • Thread