Reputation: 5086
I can't figure out why my didEndSelector isn't being called. Any ideas?
- (void) showMonitorAlertIfNeeded {
if (! self.monitorAlert && [self isHideMonitorAlert]) {
self.monitorAlert = [MMAlertController monitorAlert];
[[self.monitorAlert window] setTitle: [self applicationName]];
[self.monitorAlert beginSheetModalForWindow: [NSApp keyWindow]
modalDelegate: self
didEndSelector: @selector(monitorAlertDidEnd:returnCode:contextInfo:)
contextInfo: nil];
[[self.monitorAlert window] setLevel: NSScreenSaverWindowLevel];
}
}
- (void) monitorAlertDidEnd: (NSAlert *) alert returnCode: (NSInteger) code contextInfo: (id) contextInfo {
switch (code) {
case NSAlertFirstButtonReturn:{
}
NSLog(@"FIRST BUTTON PRESSED");
break;
case NSAlertSecondButtonReturn:{ // don't show again.
NSLog(@"SECOND BUTTON PRESSED");
[[NSApp delegate]setIsHideMonitorAlert:NO];
}
break;
default:
break;
}
}
Upvotes: 0
Views: 388
Reputation: 5431
If [MMAlertController monitorAlert]
returns an NSAlert
that was created with alertWithMessageText:defaultButton:alternateButton:otherButton:informativeTextWithFormat:
then your switch should actually contain NSAlertDefaultReturn
and NSAlertAlternateReturn
. (If it was created in any other way then your original switch
values are correct.)
Upvotes: 3
Reputation: 952
Try to insert this line just before the switch:
NSLog(@"code: %ld", code);
Upvotes: 1