If you are not using NSApplicationMain()
NSInitializeProcess(argc,argv) needs to be called from main() if you want to access the command line arguments from Foundation API's, such as command line default values. Some platforms do not have support for accessing the command line from global variables or functions so this is necessary.
int main(int argc, const char *argv[]) {
NSInitializeProcess(argc,argv);
// ... rest of program ...
}
and of course sadly we typically have to use #ifdef's
int main(int argc, const char *argv[]) {
#ifndef __APPLE__
NSInitializeProcess(argc,argv);
#endif
// ... rest of program ...
}
If you are using NSApplicationMain like so:
int main(int argc, const char *argv[]) {
return NSApplicationMain(argc, argv);
}
You don't need to use NSInitializeProcess as NSApplicationMain calls NSInitializeProcess.
While I would agree this this is not the most transparent way of initializing the command line arguments it saves the hassle of maintaining custom C runtime initialization for each platform.
