Function

NSApplicationMain

Called by the main function to create and run the application.

Declaration

int NSApplicationMain(int argc, const char * _Nonnull *argv);

Parameters

argc

The number of arguments in the argv parameter.

argv

An array of pointers containing the arguments that were passed to the application at startup.

Return Value

This method never returns a result code. Instead, it calls the exit function to exit the application and terminate the process. If you want to determine why the application exited, you should look at the result code from the exit function instead.

Discussion

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, and you typically call it only once from your application’s main function, which is usually generated automatically by Xcode.

Special Considerations

NSApplicationMain itself ignores the argc and argv arguments. Instead, Cocoa gets its arguments indirectly via _NSGetArgv, _NSGetArgc, and _NSGetEnviron (see <crt_externs.h>).

See Also

Application

NSApplication

An object that manages an app’s main event loop and resources used by all of that app’s objects.

NSRunningApplication

An object that can manipulate and provide information for a single instance of an app.

NSApplicationDelegate

A set of methods that delegates of NSApplication objects can implement.