Reputation: 16345
I have a console program which is linked to the Foundation framework on Mac. How do I find out the folder the executable is in?
Upvotes: 0
Views: 74
Reputation: 243156
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];
Upvotes: 4
Reputation: 61228
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.
Upvotes: 0