Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calling an NSAlert from didEndSelector of another NSAlert

I need to bring up an NSAlert based on the response from another NSAlert. However, when I try to call it from the didEndSelector of the first one, all kinds of nasty things happen (like my document window disappearing and warnings about ordering problems printing to console).

Any thoughts?

like image 523
toastie Avatar asked Dec 31 '25 19:12

toastie


1 Answers

What you're trying to do is "chain" the alerts.

To do this you need to call orderOut: on the alert window.

Here's the documentation:

If you want to dismiss the sheet from within the alertDidEndSelector method before the modal delegate carries out an action in response to the return value, send orderOut: (NSWindow) to the window object obtained by sending window to the alert argument. This allows you to chain sheets, for example, by dismissing one sheet before showing the next from within the alertDidEndSelector method. Note that you should be careful not to call orderOut: on the sheet from elsewhere in your program before the alertDidEndSelector method is invoked.

like image 71
Leibowitzn Avatar answered Jan 02 '26 10:01

Leibowitzn



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!