中
int main(int argc, char *argv[])
{
strncpy(argv[1], "fookBar", 7);
return NSApplicationMain(argc, (const char **)argv);
}
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
// Insert code here to initialize your application
NSArray *args = [[NSProcessInfo processInfo] arguments];
}
applicationdidfinishlaunching中的args数组并未显示主为argv [1]的呼声。?为什么?
根据Apple Doc
" nsapplicationmain本身忽略了argc和argv参数。相反,可可通过_nsgetArgv,_nsgetArgc和_nsgetenvionr(参见)间接获得参数。"
这就是为什么即使您对argv进行更改的原因,它也不会反映在applicationdidfinishlaunching