Get current user's home directory

前端 未结 3 880
终归单人心
终归单人心 2021-02-18 23:50

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/

3条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-19 00:43

    NSHomeDirectory: “Returns the path to the current user’s home directory.”

    Example:

    NSLog(@"Current user’s home directory is %@", NSHomeDirectory());
    

提交回复
热议问题