gpt4 book ai didi

ios - 如何在 iPhone 中执行命令行?

转载 作者:行者123 更新时间:2023-11-28 21:40:18 59 4
gpt4 key购买 nike

我想在 iPhone iOS 中使用 Xcode objective-c 项目执行命令行,我使用了 system() 函数,但它不起作用!

我在越狱的 iPhone 上安装了 ssh 并检查了那个应用程序,我在我制作的应用程序中编写了这段代码

system('id > /tmp/id');

安装并执行软件后,/tmp/id 中没有文件。

我该如何解决这个问题?如果在 Swift 中帮助我也没有任何问题,我只是想执行一个命令行。

最佳答案

您可以尝试使用 NSTask :

Using the NSTask class, your program can run another program as a subprocess and can monitor that program’s execution.

像这样:

let task = NSTask()
task.launchPath = "/bin/bash"
task.arguments = ["arg1", "arg2", "arg3"]

关于ios - 如何在 iPhone 中执行命令行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32439095/

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