[英]Mac OS - How to programmatically detect the Mac user (logged in user) is admin using Objective-C?
[英]How to get the location of the user folders on Mac OS X using Objective-C
如何使用目标C在Mac OS中获取文件的位置?
/Users/objc/Downloads/x.pdf
有什么基础课吗?
请给我一些示例代码。
不知道我是否了解您想要的内容,但是您可以通过以下方式获得用户的主目录:
NSArray *docDirs = NSSearchPathForDirectoriesInDomains(
NSDownloadsDirectory,
NSUserDomainMask, YES);
NSString *doc = [docDirs objectAtIndex:0];
然后可以构造路径:
NSString *path = [NSString stringWithFormat:@"%@/x.pdf", doc];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.