Re: returnCode from beginSheetModalForWindow is incorrect?
Re: returnCode from beginSheetModalForWindow is incorrect?
- Subject: Re: returnCode from beginSheetModalForWindow is incorrect?
- From: Jeremy Dronfield <email@hidden>
- Date: Thu, 17 Mar 2005 10:32:49 +0000
On 16 Mar 2005, at 1:05 pm, Geert B. Clemmensen wrote:
Hello,
Assuming you have done a beginSheetModalForWindow:... and subsequently
clicked one of the buttons, the method given as didEndSelector:, which
should have a signature like this:
- (void)alertDidEnd:(NSAlert *)alert returnCode:(int)returnCode
contextInfo:(void *)contextInfo;
is invoked. I may have misunderstood Apple's documentation, but it
says:
The returnCode identifies which button the user clicked; it is one of
the ...ButtonReturn constants described in “Constants” (page 32)
As far as I can tell, the returnCode is either 1, -1 or 0 while the 3
constants referred to are defined to have the values 1000, 1001, 1002.
Is this a well-known bug I have missed references to or am I doing
something wrong?
It looks to me as if you're mixing up the NSAlert class with the alert
functions defined by NSPanel. NSPanel defines alert return codes:
enum {
NSAlertDefaultReturn = 1,
NSAlertAlternateReturn = 0,
NSAlertOtherReturn = -1,
NSAlertErrorReturn = -2
};
whereas NSAlert defines a different set of return codes:
enum {
NSAlertFirstButtonReturn = 1000,
NSAlertSecondButtonReturn = 1001,
NSAlertThirdButtonReturn = 1002
};
You shouldn't be testing for the integer values in your code, anyway;
instead you should test for the return names - e.g. if (returnCode ==
NSAlertFirstButtonReturn)
Regards,
-Jeremy
===================================
SkoobySoft, home of viJournal and Skooby Renamer
email: email@hidden or visit:
http://freespace.virgin.net/jeremy.dronfield/skoobysoft.html
===================================
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden