How to find the residing directory of a OS X application package - programmatically

前端 未结 3 1269
予麋鹿
予麋鹿 2021-01-15 16:03

I have a OS X application as a .app package which can reside in any arbitrary location in the filesystem. Is there a way to find the current path of the package programmatic

3条回答
  •  清酒与你
    2021-01-15 16:35

    Building off the argv[0] version above, you can also get the path from:

        NSArray* arguments = [[NSProcessInfo processInfo] arguments];
    
        NSString* exe = [args objectAtIndex:0];
    

    from init or applicationDidFinishLaunching

提交回复
热议问题