Cocoa: Pass arguments to NSApplicationDelegate

前端 未结 1 752
离开以前
离开以前 2021-02-01 05:09

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 NSApplicationM         


        
1条回答
  •  遇见更好的自我
    2021-02-01 05:47

    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
    }
    

    0 讨论(0)
提交回复
热议问题