Reputation: 1055
I'm writing a simple preference pane app that will not be on the MAS and does not need to be sandboxed.
I am trying to get access to their user/library directory, or at least find the path.
I can do it this way:
NSString *filePath = @"/Users/USERNAME/Library/";
if I know their USERNAME, which I don't know how to get? Or maybe there is a better way?
Upvotes: 1
Views: 705
Reputation: 410
You can get username by calling NSUserName() function.
UPD: Understand question in wrong way. Please, use this function
// Obtain the user's real home directory
// Normally the sandbox returns the app container's user home folder, not the real one
+ (NSString *)homeDirectory {
struct passwd *pw = getpwuid(getuid());
return [NSString stringWithUTF8String:pw->pw_dir];
}
Upvotes: 1