objective-c - 将文件复制到应用程序可能无法写入的目录

标签 objective-c cocoa unix privileges

我正在编写一个应用程序,目前处于工作流程中:

-File A doesn't exist?
 -Copy file B to file A
  -Error?
   -Copy file B to file A with higher privileges

问题出在“以更高权限将文件 B 复制到文件 A”步骤中。我刚开始向管理员询问他/她的密码。我想要一个与此类似的窗口,管理员可以在其中输入密码,以便将文件复制到其他不可写的位置:

fix your image loading...

我完全不知道从哪里开始,有人可以帮助我吗?谢谢! :D

最佳答案

你可以使用AuthorizationExecuteWithPrivileges()

参见here for an examplehere for the full code to 'OSXSlightlyBetterAuth' .

关于objective-c - 将文件复制到应用程序可能无法写入的目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3894720/

相关文章:

iOS:Xcode 中的 ImageMagick 编译器警告

iphone - 添加 UIButtonTypeDetailDisclosure - 逻辑问题

cocoa - 如何创建自定义模式 NSWindow?

objective-c - 来自两个 NSImage 的 NSImage

regex - Unix find 不尊重正则表达式

Java "tail -f"包装器

bash - "Filename argument required"从 bash_profile 运行 shell 命令时出现警告

ios - 使用 Objective-C 下载 AWS S3 文件成功然后不成功

macos - launchd 何时注册事件?

objective-c - 如何在从 NSMutableData 读取的 NSInputStream 上发出 NSStreamEventEndEncountered 信号