开发者

Find out the working folder in a Foundation executable?

I have a console program whi开发者_StackOverflowch is linked to the Foundation framework on Mac. How do I find out the folder the executable is in?


Even though the tool is not in a bundle, you can still use some of the NSBundle methods. For example:

NSString * binaryPath = [[NSBundle mainBundle] executablePath];
NSString * executableFolder = [binaryPath stringByDeletingLastPathComponent];


What about [[NSBundle mainBundle] bundlePath]


The first argument passed to main() ( argv[0] ) is the path to the executable itself. If you wrote said console program, you could get it that way.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜