In the documentation for NSApplicationMain, it says:
Creates the application, loads the main nib file from the application’s main bundle, and runs the application. You must call this function from the main thread of your application [...].
The "main thread" obviously refers to the first thread of the program, where
main(argc, argv) starts. A quick look through the NSThread documentation reveals
+ (BOOL)isMainThread, which can be used to determine whether the current thread is the "main" one or not. I ran some tests: this method works regardless of whether
NSApplicationMain has been called yet.
My question has two (somewhat related) parts:
- What is so special about the main thread for
- How does Cocoa identify the main thread in the first place?