Подтвердить что ты не робот

Cocoa: передать аргументы NSApplicationDelegate

Я создал простое приложение Cocoa (Mac OS X 10.6), и появилась точка входа:

int main(int argc, char *argv[])
{
    return NSApplicationMain(argc,  (const char **) argv);
}

и манекен AppDelegate:

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
    // how to get argc and argv?
}

и некоторые другие. Как я могу правильно передать argc и argv в свой AppDelegate?

4b9b3361

Ответ 1

Используйте +[NSProcessInfo processInfo] и -[NSProcessInfo arguments].

В делетете приложения,

- (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
}