Re: NSRunCriticalAlertPanel doesn't behave as I expected.
Re: NSRunCriticalAlertPanel doesn't behave as I expected.
- Subject: Re: NSRunCriticalAlertPanel doesn't behave as I expected.
- From: David Remahl <email@hidden>
- Date: Thu, 20 Dec 2001 17:51:19 +0100
You're making the classical mistake of assigning a new value to alertResult
instead of changing it. Remember, the equals comparison operator in C is
'=='. A single '=' assigns a new value. I believe I rubbed your nose in the
mud enough now, for a simple mistake ;-)
/ david
>
having just read the docs for AlertPanels, I wrote the code below:
>
>
However when I test the app I get the following in the Log (whichever button
>
I pressed.)
>
>
2001-12-20 16:25:00.400 foobar[1570] NSAlertOtherReturn.
>
2001-12-20 16:25:02.861 foobar[1570] NSAlertDefaultReturn.
>
>
>
Does anyone have any ideas what's going wrong.
>
Please excuse me if this is a stupid question.
>
>
Thanks, Diggory.
>
>
>
>
#import "MyObject.h"
>
>
@implementation MyObject
>
>
- (IBAction)myAction:(id)sender
>
{
>
int alertResult;
>
>
alertResult=NSRunCriticalAlertPanel(@"Really remove?", @"really remove
>
the thing?" ,@"Cancel" ,@"OK" ,@"ho ho ho!");
>
if (alertResult=NSAlertAlternateReturn){ // If the user pressed "OK"
>
NSLog(@"NSAlertAlternateReturn.");
>
}
>
if (alertResult=NSAlertDefaultReturn){ // If the user pressed
"cancel"
>
NSLog(@"NSAlertDefaultReturn.");
>
}
>
if (alertResult=NSAlertOtherReturn){ // If the user pressed "ho
ho ho!
>
"
>
NSLog(@"NSAlertOtherReturn.");
>
}
>
>
}
>
>
@end