Skip navigation.
 
mlRe: File's Owner
FROM : Andy Lee
DATE : Fri May 23 22:55:13 2008

On May 23, 2008, at 2:49 PM, Johnny Lundy wrote:
> I decided to once again go verbatim through Cocoa Fundamentals. So 
> far it has been largely "uh-huh, yep", but the File's Owner, my 
> nemesis, comes up again.


I tried to answer your File's Owner and NSApp questions last week 
(copied below).  If you can indicate at what point in my explanations 
you start getting lost, I can try to explain better.

Again, I'm sensing a very fundamental disconnect, perhaps more 
fundamental than you realize.  Anybody can recite documentation, so 
there's no need to tell us that and no need to recite the 
documentation.  I think it would be more helpful to tell us at what 
*part* of the documentation you start to get lost, and what 
specifically is confusing about it, perhaps as relates to your other 
programming experience.  If the answer is that you draw a complete 
blank, then we shouldn't be addressing that issue at all; you need to 
step back to a more fundamental level and see if you feel fluent at 
that level.

--Andy


Here's my reply from last week:

On May 15, 2008, at 11:11 AM, Andy Lee wrote:

> On May 14, 2008, at 10:33 PM, Johnny Lundy wrote:

>> So it's the application instance. I don't understand what the 
>> application instance is. I can recite the documentation, which says 
>> it is a shared instance of NSApplication, also known as NSApp which 
>> is a global variable, none of which help me.

>
> To me this indicates a very fundamental disconnect, because what you 
> recited explains NSApp perfectly.  I can't tell where the disconnect 
> is, so I'll try to spell this out quickly.  No offense intended here 
> -- I honestly don't know where the disconnect is.
>
> You are writing a Cocoa application.  There is a class called 
> NSApplication that represents the concept of a Cocoa application. 
> That's the purpose of a class in an object-oriented language, to 
> describe a *class* of things conceptually.  Classes are usually 
> named for the thing they describe -- hence "NSApplication". 
> NSApplication handles the generic things that Cocoa applications do: 
> managing the main menu, managing the window list, dealing with mouse 
> and keyboard events, and so on.
>
> Cocoa applications create objects (instances of classes).  That's 
> what they do all day.  Objects get created, they send messages to 
> each other, they get dealloc'ed.  Thousands and thousands of 
> objects, all day long.  In your application there is one special 
> object that is an instance of NSApplication.  It represents the 
> application itself.  I repeat: there is an object in your 
> application that represents the running application itself.  There 
> is only one such object, and it is stored in a global variable 
> called NSApp.  That is what "application instance" means.
>

>> Why would someone bind to File's Owner? What specifically is it?

>
> Unlike most other objects in a nib file (First Responder being the 
> exception), File's Owner is not a specific object.  It is a 
> placeholder for an "owner" object that will be specified when the 
> nib file is loaded.  You edit a nib file knowing that it will be 
> loaded at some point in your program, and *at that future time* the 
> owner of the file (hence "File's Owner") will be specified.
>
> The file's owner gives your program access to the objects in the nib 
> file, through the connections you made to it in the nib.
>
> I think newcomers sometimes assume that when you load a nib you get 
> some sort of NibObject that you can query to get at the objects in 
> the nib, perhaps using the name you assigned in the nib file.  This 
> is an understandable assumption, but you don't get any such object. 
> You need to specify a file's owner for the nib (using the second 
> argument to +loadNibNamed:owner:), and you need to have constructed 
> the nib so it connects the file's owner to at least one of its 
> objects.
>
> --Andy

Related mailsAuthorDate
mlFile's Owner Johnny Lundy May 23, 20:49
mlRe: File's Owner Matt Long May 23, 21:13
mlRe: File's Owner Erik Buck May 23, 21:30
mlRe: File's Owner Ken Thomases May 23, 21:33
mlRe: File's Owner Brian Stern May 23, 22:00
mlRe: File's Owner Shawn Erickson May 23, 22:27
mlRe: File's Owner Andy Lee May 23, 22:55
mlRe: File's Owner Shawn Erickson May 23, 23:07
mlRe: File's Owner Shawn Erickson May 23, 23:11
mlRe: File's Owner Steve Weller May 24, 00:17
mlRe: File's Owner Hamish Allan May 24, 00:30
mlRe: File's Owner Julien Jalon May 24, 01:36
mlRe: File's Owner Johnny Lundy May 24, 02:21
mlRe: File's Owner Johnny Lundy May 24, 03:19
mlRe: File's Owner Jonathan Hess May 24, 03:32
mlRe: File's Owner Erik Buck May 24, 03:55
mlRe: File's Owner Jason Stephenson May 24, 03:57
mlRe: File's Owner Johnny Lundy May 24, 04:31
mlRe: File's Owner Scott Ribe May 24, 04:38
mlRe: File's Owner Andy Lee May 24, 04:58
mlRe: File's Owner Scott Ribe May 24, 05:01
mlRe: File's Owner Jonathan Hendry May 24, 05:41
mlRe: File's Owner Andreas Mayer May 24, 06:39
mlRe: File's Owner Paul Sargent May 24, 12:49
mlRe: File's Owner Sherm Pendley May 24, 13:02
mlRe: File's Owner Hamish Allan May 24, 14:12
mlRe: File's Owner Johnny Lundy May 25, 00:25
mlRe: File's Owner Ken Thomases May 25, 04:57
mlRe: File's Owner Johnny Lundy May 25, 09:15
mlRe: File's Owner Scott Anguish May 25, 09:49
mlRe: File's Owner Jens Alfke May 25, 09:52
mlRe: File's Owner Ken Thomases May 25, 10:17
mlRe: File's Owner Paul Thomas May 25, 10:31
mlRe: File's Owner Roland King May 25, 11:01
mlRe: File's Owner mmalc crawford May 25, 11:14
mlRe: File's Owner Ken Thomases May 25, 11:44
mlRe: File's Owner mmalc crawford May 25, 12:20
mlRe: File's Owner Graham Cox May 25, 14:02
mlRe: File's Owner Andy Lee May 25, 15:31
mlRe: File's Owner Johnny Lundy May 25, 18:13
mlRe: File's Owner mmalc crawford May 25, 19:17
mlRe: File's Owner mmalc crawford May 25, 19:22
mlRe: File's Owner Andy Lee May 25, 19:30
mlRe: File's Owner mmalc crawford May 25, 19:42
mlRe: File's Owner Hamish Allan May 25, 20:58
mlRe: File's Owner Johnny Lundy May 25, 21:12
mlFile's Owner Johnny Lundy May 25, 21:27
mlRe: File's Owner Jens Alfke May 25, 21:51
mlRe: File's Owner Sherman Pendley May 25, 21:53
mlRe: File's Owner James Merkel May 25, 22:14
mlRe: File's Owner Kyle Sluder May 26, 03:41
mlRe: File's Owner Scott Anguish May 26, 08:21
mlRe: File's Owner Uli Kusterer May 26, 09:54
mlRe: File's Owner Uli Kusterer May 26, 10:17
mlRe: File's Owner Quincey Morris May 26, 19:49
mlRe: File's Owner dream cat7 May 27, 03:24
mlRe: File's Owner Andreas Mayer May 27, 05:34
mlRe: File's Owner Scott Ribe May 27, 06:24
mlRe: File's Owner Hamish Allan May 27, 11:11
mlRe: File's Owner Andy Lee May 27, 14:34
mlRe: File's Owner Andy Lee May 27, 14:48
mlRe: File's Owner Kyle Sluder May 27, 15:52
mlRe: File's Owner Andy Lee May 27, 16:06
mlRe: File's Owner Mike Abdullah May 27, 17:51
mlRe: File's Owner Andy Lee May 27, 19:36
mlRe: File's Owner Quincey Morris May 27, 20:02
mlRe: File's Owner Andy Lee May 27, 20:50
mlRe: File's Owner Quincey Morris May 27, 22:40
mlRe: File's Owner Ken Thomases May 27, 22:47
mlRe: File's Owner Andy Lee May 27, 23:04
mlRe: File's Owner Alex Kac May 27, 23:19
mlRe: File's Owner Gary L. Wade May 27, 23:55
ml[moderator] Re: File's Owner Scott Anguish May 28, 00:13