Skip navigation.
 
mlRe: Bypassing Interface Builder
FROM : Andy Lee
DATE : Thu May 15 17:11:24 2008

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
mlBypassing Interface Builder colo May 14, 16:36
mlRe: Bypassing Interface Builder I. Savant May 14, 17:11
mlRe: Bypassing Interface Builder colo May 14, 17:35
mlRe: Bypassing Interface Builder I. Savant May 14, 17:43
mlRe: Bypassing Interface Builder Andy Lee May 14, 17:50
mlRe: Bypassing Interface Builder colo May 14, 17:53
mlRe: Bypassing Interface Builder I. Savant May 14, 17:58
mlRe: Bypassing Interface Builder David Wilson May 14, 17:59
mlRe: Bypassing Interface Builder I. Savant May 14, 18:01
mlRe: Bypassing Interface Builder I. Savant May 14, 18:05
mlRe: Bypassing Interface Builder Gregory Weston May 14, 18:06
mlRe: Bypassing Interface Builder glenn andreas May 14, 18:13
mlRe: Bypassing Interface Builder Wayne Packard May 14, 18:26
mlRe: Bypassing Interface Builder Andy Lee May 14, 18:37
mlRe: Bypassing Interface Builder Stefan Werner May 14, 18:46
mlRe: Bypassing Interface Builder Bill Bumgarner May 14, 19:00
mlRe: Bypassing Interface Builder Boyd Collier May 14, 19:34
mlRe: Bypassing Interface Builder colo May 14, 19:37
mlRe: Bypassing Interface Builder Julius Guzy May 14, 22:05
mlRe: Bypassing Interface Builder Torsten Curdt May 14, 22:49
mlRe: Bypassing Interface Builder colo May 15, 00:53
mlRe: Bypassing Interface Builder Graham Cox May 15, 01:26
mlRe: Bypassing Interface Builder Graham Cox May 15, 01:41
mlRe: Bypassing Interface Builder colo May 15, 02:14
mlRe: Bypassing Interface Builder Johnny Lundy May 15, 02:15
mlRe: Bypassing Interface Builder Graham Cox May 15, 02:29
mlRe: Bypassing Interface Builder I. Savant May 15, 02:43
mlRe: Bypassing Interface Builder Graham Cox May 15, 02:45
mlRe: Bypassing Interface Builder I. Savant May 15, 02:51
mlRe: Bypassing Interface Builder I. Savant May 15, 02:54
mlRe: Bypassing Interface Builder Andy Lee May 15, 03:02
mlRe: Bypassing Interface Builder Graham Cox May 15, 03:02
mlRe: Bypassing Interface Builder Andy Lee May 15, 03:06
mlRe: Bypassing Interface Builder I. Savant May 15, 03:07
mlRe: Bypassing Interface Builder Andy Lee May 15, 03:08
mlRe: Bypassing Interface Builder I. Savant May 15, 03:09
mlRe: Bypassing Interface Builder I. Savant May 15, 03:15
mlRe: Bypassing Interface Builder Andy Lee May 15, 03:29
mlRe: Bypassing Interface Builder Julius Guzy May 15, 03:35
mlRe: Bypassing Interface Builder I. Savant May 15, 03:37
mlRe: Bypassing Interface Builder Johnny Lundy May 15, 04:33
mlRe: Bypassing Interface Builder Julius Guzy May 15, 04:36
mlRe: Bypassing Interface Builder Johnny Lundy May 15, 04:54
mlRe: Bypassing Interface Builder Graham Cox May 15, 05:43
mlRe: Bypassing Interface Builder Uli Kusterer May 15, 07:50
mlRe: Bypassing Interface Builder Uli Kusterer May 15, 07:55
mlRe: Bypassing Interface Builder Uli Kusterer May 15, 08:15
mlcocoa mentoring (was Re: Bypassing Interface Builder) Torsten Curdt May 15, 15:36
mlRe: cocoa mentoring (was Re: Bypassing Interface Builder) Paul Bruneau May 15, 15:47
mlRe: cocoa mentoring (was Re: Bypassing Interface Builder) Uli Kusterer May 15, 16:08
mlcocoaheads frankfurt (was Re: cocoa mentoring) Torsten Curdt May 15, 16:44
mlRe: cocoa mentoring (was Re: Bypassing Interface Builder) Torsten Curdt May 15, 16:51
mlRe: Bypassing Interface Builder Andy Lee May 15, 17:11
mlRe: Bypassing Interface Builder Johnny Lundy May 15, 18:40
mlRe: cocoa mentoring (was Re: Bypassing Interface Builder) Dennis Munsie May 15, 19:34
mlRe: Bypassing Interface Builder Paul Sargent May 15, 20:07
mlRe: Bypassing Interface Builder Uli Kusterer May 15, 20:48
mlRe: Bypassing Interface Builder Shawn Erickson May 15, 22:20
mlRe: Bypassing Interface Builder Shawn Erickson May 15, 22:30
mlRe: Bypassing Interface Builder Johnny Lundy May 15, 22:32
mlRe: cocoa mentoring (was Re: Bypassing Interface Builder) Torsten Curdt May 15, 23:03