I have created the simple Cocoa application (Mac OS X 10.6) and there have appeared the entry point:
int main(int argc, char *argv[])
{
return NSApplicationMain(argc, (const char **) argv);
}
and AppDelegate dummy:
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
// how to get argc and argv?
}
and some other. How could I pass the argc and argv to my AppDelegate right way?
Use +[NSProcessInfo processInfo] and -[NSProcessInfo arguments].
In your application delegate,
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
NSArray *args = [[NSProcessInfo processInfo] arguments];
// use -objectAtIndex: to obtain an element of the array
// and -count to obtain the number of elements in the array
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With