Question about relation between File's Owner, First Responder and controller object...
Question about relation between File's Owner, First Responder and controller object...
- Subject: Question about relation between File's Owner, First Responder and controller object...
- From: Mikael Arctaedius <email@hidden>
- Date: Mon, 11 Apr 2005 18:08:19 +0200
Hi all!
I have a kind of basic question but it is very important for
me to get a good understanding of the central parts of a NIB
file. Right know I can get most things to work as I expect,
but I feel that I don't have a complete understanding of
these things. And some things does not work as I expect...
I have two books on Cocoa programming but I really can't find
enough information on this question in either book (neither
Hillegass nor Garfinkel&Mahoney speak a lot on this topic.)
I'm developing a document-based application which have a
number of buttons and text fields in the (main) window. The
application has document specific menu items in the File
menu, i.e. items that should be enabled when a document is
open but disabled when no document is open.
I have one NIB-file SystemWindow.nib which contains MainMenu,
File's Owner, First Responder, my Window and an instance of
my controllerclass, SystemController.
The File's Owner is set to be an instance of SystemController.
The buttons I've added to my window are connected to the
SystemController, i.e. Target/Action is set to point to a
method in SystemController. Is this right? Or should they be
connected to File's Owner? If a set a breakpoint in the
action-method, I can see by looking at the value of self that
File's Owner is not the same instance as SystemController...
The outlets from the SystemController instance in the NIB-file
is connected to the textfields in the window. Is that correct?
Or should it be a outlet from File's Owner?
In my SystemController class I have a method windowDidLoad but
this method is only called for one instance, File's Owner.
Some items (e.g. New, Open) in the File menu are already
connected by InterfaceBuilder to First Responder.
The "non-standard" item in the File menu, are connected to
File's Owner. Is this correct?
If I make all connections (target/actions and outlets) to the
File's Owner everything works as long as a window (document) is
open. But when no window is open, I get a crash when clicking
on the File menu. Appearently because no window is open and one
of the items is connected to a window.
So where shall the target/actions be connected? To the File's Owner
or the instance of SystemController? Is it wrong to have an instance
of SystemController in the NIB-file? How can I add an item to the
File menu which shall be enabled when a document is open and
disabled when no document is open? Why are there two instances of
SystemController?
Thanks
Mikael Arctaedius
Stockholm, Sweden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden