I'm developing a Cocoa Objective-C application that will run on Mac OS X. I need to get the full path of the current user's home directory:
/Users/MyUser/
Is there a standard function that does that in Objective-C/Cocoa?
NSHomeDirectory
: “Returns the path to the current user’s home directory.”
Example:
NSLog(@"Current user’s home directory is %@", NSHomeDirectory());
Since macOS 10.12 you can also use FileManager.default.homeDirectoryForCurrentUser
, see the documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With