gpt4 book ai didi

objective-c - 使用 nsfilemanager 设置文件夹的权限

转载 作者:行者123 更新时间:2023-11-30 12:13:42 24 4
gpt4 key购买 nike

我为 Mac OS 创建应用程序并有一些问题。如何使用 NSFileManager 或其他方式更改文件夹的权限?

使用查找器很容易,但我需要以编程方式执行此操作。

enter image description here

最佳答案

只要您有足够的权限,您就可以使用以下方法做到这一点

- (BOOL)setAttributes:(NSDictionary<NSFileAttributeKey,id> *)attributes ofItemAtPath:(NSString *)path error:(NSError * _Nullable *)error

这些键是相关的

  • NSFileOwnerAccountName设置所有者
  • NSFileGroupOwnerAccountName设置组
  • NSFilePosixPermissions数字权限

关于objective-c - 使用 nsfilemanager 设置文件夹的权限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45699420/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com