获取当前用户的主目录 [英] Get current user's home directory

查看:341
本文介绍了获取当前用户的主目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个可在Mac OS X上运行的Cocoa Objective-C应用程序。我需要获取当前用户主目录的完整路径:

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/

在Objective-C / Cocoa中是否有一个标准函数?

Is there a standard function that does that in Objective-C/Cocoa?

推荐答案

NSHomeDirectory :返回当前用户主目录的路径。

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

示例:

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

这篇关于获取当前用户的主目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆