Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c Cocoa:将参数传递给nsApplicationLegate_Objective C_Xcode_Macos_Cocoa_Command Line Arguments - Fatal编程技术网

Objective c Cocoa:将参数传递给nsApplicationLegate

Objective c Cocoa:将参数传递给nsApplicationLegate,objective-c,xcode,macos,cocoa,command-line-arguments,Objective C,Xcode,Macos,Cocoa,Command Line Arguments,我创建了简单的Cocoa应用程序(Mac OS X 10.6),出现了入口点: int main(int argc, char *argv[]) { return NSApplicationMain(argc, (const char **) argv); } 和AppDelegatedummy: - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { // how to get argc

我创建了简单的Cocoa应用程序(Mac OS X 10.6),出现了入口点:

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

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

还有其他一些。如何正确地将argc和argv传递给我的
AppDelegate

使用
+[NSProcessInfo processInfo]
-[NSProcessInfo参数]

在应用程序委托中

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