Re: MainMenu and NSDocument problems
Re: MainMenu and NSDocument problems
- Subject: Re: MainMenu and NSDocument problems
- From: Darren Ford <email@hidden>
- Date: Thu, 9 Oct 2003 11:20:33 +1000
Hi mate,
Thanks for the info -- however I'm still having problems implementing
your suggestion.
> make a First Responder with the method name
Do you mean, create a new action on the first responder object in IB?
(ie. ctrl-click on the FirstResponder object in the Classes tab?) Or
do i need to create a new class of some sort? I've tried a number of
things and they still seem to end up with the same result (ie. nil
objects).
Thanks for your help.
Darren.
Sounds like you're linking the menu item directly to your instance in
IB. Instead, make a First Responder with the method name you're
calling and link to that. The frontmost document will get the call
and then you will have access to that instance's variables. The way
it is now it's calling a method on a blank instance of your NSDocument
class rather than the frontmost one.
I ran into that not two weeks ago. Really frustrating thing, and it's
not really documented anywhere that I can tell, but I suppose proper
use of First Responder would preclude documenting things like this. ;)
So, rule of thumb: link all menu items that operate on the front
document to First Responder actions in a document-based program.
PS: You'll also sometimes get NSCFArray out of bounds errors with
this. Same deal there.
On Oct 2, 2003, at 7:37 AM, Darren Ford wrote:
Hi all,
I have a small project that I'm working on, based on a multiple
document interface (the first I've attempted).
I'm attempting to write the document out to a file by overriding
writeToFile: in my NSDocument-based (iSDocument) class. The callback
to the Save menu is intercepted in my iSDocument class correctly,
however I'm finding that the values of my member variables in the
class (specifially NSTextField items) are all nil pointers.
These pointer values are fine when eg. I click a button on my
interface and enter an action method, however when I go through the
Save menu item they all appear as nil.
Is there something that I haven't hooked up properly in my
MainMenu,nib file?
Thanks -- Darren.
_______________________________________________
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.
--
Adam
_______________________________________________
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.