Hi,
I am having some issues binding an NSMenuItem's "value" binding to a BOOL.
I simplified the problem to this:
1) The menu item must call the action method that changes the value of the BOOL otherwise it doesn't work (i.e. if an NSButton calls a method that changes the value of the BOOL then the menu item won't update)
2) Even if the action method makes the BOOL a constant (i.e. enabled = YES
), the "value" of the menu item still alternates.
Any ideas? I'm so confused!
Here is the code:
MenuBindings_AppDelegate.h
#import <Cocoa/Cocoa.h>
@interface Menu_BindingsAppDelegate : NSObject <NSApplicationDelegate>
{
BOOL foo;
}
- (IBAction)toggle:(id)sender;
- (IBAction)makeYes:(id)sender;
@property BOOL foo;
@end
Menu_BindingsAppDelegate.m
@implementation Menu_BindingsAppDelegate
@synthesize foo;
- (IBAction)toggle:(id)sender
{
[self setFoo:!foo];
}
- (IBAction)makeYes:(id)sender
{
[self setFoo:YES];
}
@end
In my nib, I have a button connected to the -makeYes: action and a menu item connected to the -toggle: action. The menu item's "value" binding is bound to the app delegate's "foo" attribute.
Thanks.