hi i want to display a alert message when clicked close button of application and if press 'yes' on message application is exit but is 'no' on message application not close.
i am doing this but it not works fine on 'no'
thanks.
i am doing this but it not works fine on 'no'
Code:
- (void)windowWillClose:(NSNotification *)aNotification
{
NSAlert *alert = [NSAlert alertWithMessageText:@"\nDo you really want exit?"
defaultButton:@"Yes" alternateButton:NO otherButton:@"No"
informativeTextWithFormat:@""];
int result = [alert runModal];
if(result == NSOKButton)
{
[NSApp terminate:self];
}
else
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
//return NSTerminateCancel;
}
}
thanks.