0

I am curious what constant is passed to completion handler in NSAlert method

- (void)beginSheetModalForWindow:(NSWindow *)sheetWindow completionHandler:(void (^)(NSModalResponse returnCode))handler

Is it a number like NSModalResponseStop=-1000 or NSModalResponseAbort=-1001 ? How can I know what button was pressed if there are more than one button in the alert?

wladik
  • 41
  • 4

1 Answers1

1

The button return values are the same as for beginSheetModalForWindow:modalDelegate:didEndSelector:contextInfo: . Possible values are listed under "Button Return Values" in the NSAlert documentation:

An alert’s return values for buttons are position dependent. The following constants describe the return values for the first three buttons on an alert (assuming a language that reads left to right).

enum { NSAlertFirstButtonReturn = 1000, NSAlertSecondButtonReturn = 1001, NSAlertThirdButtonReturn = 1002 };

mrwalker
  • 1,883
  • 21
  • 23