Reputation: 4124
I'm trying to open a folder "~/Library/Application Support/Mozilla"
in a Mac App using objective-c.
NSString *stringContaingPath = @"~/Library/Application Support/Mozilla";
NSURL *folderURL = [NSURL fileURLWithPath:stringContaingPath];
[[NSWorkspace sharedWorkspace] openURL: folderURL];
But each time I get the error
When I go to open it.
Though the folder does exist.
Is there something special I need to do to open the folder? I'm not trying to write to it, just open it up for the user to see.
Upvotes: 0
Views: 105
Reputation: 122381
The ~
symbol is only meaningful to the shell. You will have to expand it to /Users/username
using NSHomeDirectory()
; i.e.:
NSString *pathName = [NSHomeDirectory() stringByAppendingPathComponent:@"Library/Application Support/Mozilla"];
However this will only work in a non-sandboxed app.
Upvotes: 1