mer*_*rch 5 macos shell root nstask swift
我是Swift的新手,我正在尝试创建一个非常简单的应用程序,当你按下一个圆形按钮时执行root shell命令.
我在网上找到了以下链接,它解释了如何在swift上执行具有用户权限的shell命令,但它没有说明如何使用root权限执行此操作:http://practicalswift.com/2014/06/25/如何对执行壳的命令从-斯威夫特/
我该怎么做?
快速和脏:
NSAppleScript(source: "do shell script \"sudo whatever\" with administrator " +
"privileges")!.executeAndReturnError(nil)
Run Code Online (Sandbox Code Playgroud)
或者查看特权帮助工具,但期望更复杂.