Re: Subclassing NSDocumentController
Re: Subclassing NSDocumentController
- Subject: Re: Subclassing NSDocumentController
- From: Bruce Truax <email@hidden>
- Date: Tue, 13 Jul 2004 07:31:00 -0400
Yes I did instantiate my class so that should be all I need to do. So my
understanding of the the First Reponder is as follows, please correct me if
I am wrong:
1. I subclassed NSDocumentController and instantiated my class which will
cause it to be initialized when the nib is loaded.
2. The -init method in NSDocumentController will send the makeFirstReponder
message to register itself, and by default my subclass as the first
responder.
3. The openDocument message which is sent to First Responder upon selection
of the Open... Menu item will be automatically sent to my subclass of
NSDocumentController and not to the super class. There is no need for me to
make a connection between the Open menu item and the openDocument action in
my FileHandler subclass.
One last question. Where do all of the actions for the First Responder come
from? They are not automatically populated by the contents of any class
header files. If I understand correctly, the are all added manually and the
connection between the message and any class which responds to the message
is handled at runtime as the message is passed down the responder chain.
Thanks for the help.
Regards,
Bruce
>
Hello...
>
>
Have you actually instantiated the NSDocumentController subclass in
>
your nib (so that there is an object shown in the nib contents window
>
that represents an instance of your class)? After you drag the header
>
file for your subclass to the nib window, it should show the class
>
browser with your subclass selected. Then all you have to do is go to
>
the "Classes" menu in the menu bar and choose "Instantiate" and an
>
instance of your sublcass will be created in the nib.
>
>
The first instance of NSDocumentController or a subclass that is
>
created becomes the shared document controller for the application,
>
so when there is an instance in the MainMenu.nib (or whatever the
>
main nib is set to be in your Info.plist) it will be used and the
>
application will not create another one.
>
>
>
Hope that helps,
>
>
Louis
>
>
>
> I need to override the openDocument and newDocument methods in
>
> NSDocumentController. I have created a class called FileHandler which is a
>
> subclass of NSDocumentController with the new methods and some additional
>
> instance variables.
>
>
>
> Now that I have done this I want FileHandler to be the First Responder for
>
> my MainMenu.nib so that when the user selects Open or New, the new methods
>
> are called.
>
>
>
> I have dragged the FileHandler.h file into the MainMenu.nib, but how do I
>
> make this subclass act as the first item in the responder chain ahead of
>
> NSDocumentController?
>
>
>
>
>
> --
>
> ____________________________________________________________
>
> Bruce E. Truax email: email@hidden
>
>
>
--
____________________________________________________________
Bruce E. Truax email: email@hidden
Optical Engineering Consultant
Diffraction Limited Design LLC
388 Wedgewood Road voice: 860-276-0450
Southington, CT 06489 fax: 860-620-9026
http://www.dld-llc.com
_____________________________________________________________
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.