Objective c Cocoa:将参数传递给nsApplicationLegate
我创建了简单的Cocoa应用程序(Mac OS X 10.6),出现了入口点: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
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
}