using currentDocument accessors to validateMenuItem
using currentDocument accessors to validateMenuItem
- Subject: using currentDocument accessors to validateMenuItem
- From: Ian <email@hidden>
- Date: Sat, 25 May 2002 01:38:43 +0100
I have a document based app, which has an NSDocumentController subclass
looking after such things as menu validation and so on. In my -
(BOOL)validateMenuItem:(NSMenuItem *)anItem method I'm setting the state
of some NSMenuItems according to the BOOL value of whatever they
represent in the current document. This is how I'm doing it:
[someBoolMenuItem setState:[[self currentDocument] someBool]];
[... and so on for other menu items that need to be
checked/unchecked ...]
return [super validateMenuItem:anItem];
so that I can have the menu item checked or not according to whether the
current document returns YES or NO for someBool.
It all works perfectly, but I get the following warnings at compile time:
warning: cannot find method.
warning: return type for `someBool' defaults to id
warning: passing arg 1 of `setState:' makes integer from pointer without
a cast
I understand that it's not known 'till runtime who can answer these
messages, hence the warning, but I also understand that it's generally
*very bad* practice to ignore such warnings.
(BTW casting [[self currentDocument] someBool] to int removes the
'integer from pointer' warning as expected but not the others)
I was wondering if there's a defacto way to do this that I'm missing?
Any comments appreciated. (apologies if I'm missing the point ;)
Cheers.
_______________________________________________
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.