I have a custom class for NSButton called `MyButton` where I post a notification for a quicksave
`MyButton.m`:
in `AppDelegate` I get the notification for the quick save:
`AppDelegate.m`:
Via the `NSLog "Saving..."` I see that the saveAction is called 2 times. Why? Thanks in advance
`MyButton.m`:
Code:
-(void)mouseDown:(id)sender{
[super mouseDown:sender];
[super mouseUp:sender];
[[NSNotificationCenter defaultCenter] postNotificationName:@"quickSave" object:nil userInfo:nil];
}
`AppDelegate.m`:
Code:
- (IBAction)saveAction:(id)sender{
NSLog(@"Saving...");
NSError *error = nil;
if (![[self managedObjectContext] commitEditing]) {
NSLog(@"%@:%@ unable to commit editing before saving", [self class], NSStringFromSelector(_cmd));
}
if (![[self managedObjectContext] save:&error]) {
[[NSApplication sharedApplication] presentError:error];
}
}
-(void)awakeFromNib{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(saveAction:) name:@"quickSave" object:nil];
}