Cory <cory.imdieke@[EMAIL PROTECTED]
> writes:
> Hello, I'm a new Mac App Programmer used to Java and a little bit of C+
> +, and I'm trying to wrap my mind around Delegates. How do they work,
> what are they for, etc?
Apple says it far better than I could:
<http://developer.apple.com/do***entation/Cocoa/Conceptual/CocoaFundamentals/CommunicatingWithObjects/chapter_6_section_4.html>
> The other basic concept that I'm not too firm on is the File's Owner
> in a nib file. What exactly does it point to, and what defines what it
> is?
Nibs are loaded by methods like NSWindowController's
-initWithWindowNibName:owner:, and as the name of the method implies, the
owner is passed as a parameter when this method is called. If the method
-initWithWindowNibName: is used instead, it simply calls the first method,
passing itself as the owner.
> If I open another window from a method in my AppController with a
> button in my Main nib file, is the new window's File's Owner my
> AppController, or the window that called the method in the
> AppController?
That depends on how you create the NSWindowController instance. You can
let it assume owner****p of the nib, or you can assign an owner object of
your choice.
> What's the Owner of the Main nib?
NSApp, the global NSApplication singleton. NSApplicationMain(), called
from
main(), p***** NSApp as the owner to -initWithWindowNibName:owner: to load
the MainMenu.nib.
> I have a alright idea of Outlets and so on, basically a way to access
> an object instance in a nib file from code, is that the basic idea?
Yeah, pretty much. When a nib is loaded, an object graph is deserialized
from the .nib bundle. Outlets are pointers to some of those objects, and
the nib loading machinery will attempt to resolve those pointers after
the objects have been deserialized. To do so, it will look for a -setFoo:
accessor method first, then for instance variables - if it fails to find
either of those in the nib's owner object, it will NSLog() a complaint.
Note that outlet resolution isn't fully KVC compliant - it doesn't go
through setValue:forKey:, it takes the above steps on its own.
sherm--
--
My blog: http://shermspace.blogspot.com
Cocoa programming in Perl: http://camelbones.sourceforge.net


|