• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: returnCode from beginSheetModalForWindow is incorrect?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: returnCode from beginSheetModalForWindow is incorrect?


  • Subject: Re: returnCode from beginSheetModalForWindow is incorrect?
  • From: todd ransom <email@hidden>
  • Date: Thu, 17 Mar 2005 08:59:16 -0700

I have seen the same thing. I created a new NSAlert object and gave it buttons called OK & Cancel. The return codes I get don't match the documentation. Instead of NSAlertFirstButtonReturn I get NSOKButton. It is either a bug in NSAlert or a bug in the documentation.

TR

On Mar 17, 2005, at 3:32 AM, Jeremy Dronfield wrote:

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

_______________________________________________ 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
References: 
 >returnCode from beginSheetModalForWindow is incorrect? (From: "Geert B. Clemmensen" <email@hidden>)
 >Re: returnCode from beginSheetModalForWindow is incorrect? (From: Jeremy Dronfield <email@hidden>)

  • Prev by Date: Re: Open MyDocument from MainMenu
  • Next by Date: NSURL Caching Question
  • Previous by thread: Re: returnCode from beginSheetModalForWindow is incorrect?
  • Next by thread: Re: returnCode from beginSheetModalForWindow is incorrect?
  • Index(es):
    • Date
    • Thread