Question

I am designing an application to connect remotely to another computer. I want to display an NSAlertPanel on connecting however it is 'blocking' the remote side from continuing with the session until OK is pressed with the usual NSAlertPanel setup.

Is there a way to have an NSAlertPanel which is non-blocking? Thanks.

Was it helpful?

Solution

When you run your alert panel modally, you block the run loop of the associated thread, which is the main thread in this case.

To display a window on connection, you can use custom sheets. It's easy to use and explained in the documentation page below:

https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Sheets/Tasks/UsingCustomSheets.html

However, if you need to run your alert modally, an alert that is blocking interactions with the whole application, you may need to move your connection part to another thread, which is a good practice in both cases.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top