Issue 1: I want to show an alert window or message box before the main window of the application is launched. When I'm using the NSRunAlertPanel() it is not showing the alert window. It is directly launching the application's main window.
Issue 2: I want to create a modal (login dialog) and message boxes in a thread spawned from the main thread.
Issue2: I want to create an Modal (login dialog) and message boxes in an thread spanned from the main thread.
In Cocoa, nearly all UI code must run on the main thread. There are a few limited, well-defined exceptions (e.g., the opt-in threaded drawing introduced in Snow Leopard), but the general rule is to not run UI code on another thread.
Besides, you don't need a thread anyway. It's not like the modal dialog is going to be computationally intensive.
Send NSApp a runModalForWindow:
message, passing the dialog. This will run the dialog on the main thread, blocking the rest of your UI. If you don't want to block the UI (and you generally shouldn't), just make it key and order it front, like usual.