문제

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.

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top