I am having some problems linking NSMenuItem binding to BOOL.
I simplified the problem:
1) A menu item should call an action method that changes the BOOL value, otherwise it will not work (i.e. if NSButton calls a method that changes the BOOL value, the menu item will not be updated)
2) Even if the action method makes BOOL 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 associated with the -makeYes: action and a menu item associated with the -toggle: action. The "value" binding of the menu item is bound to the "foo" attribute of the application delegation.
Thank.