全新的swift,试图开发一个小型GUI。实用程序应用程序使用NSTask进行一些系统调用。我在我的论点中犯了一个小的拼写错误......嗯.. NSTask.launch只是......挂起而且永远不会返回。我在这里使用通知从另一篇文章中找出了我的错误,但我想了解为什么NSTask.launch()无法返回。我希望它会以不愉快的终止状态返回。
[编辑:提供一些示例代码]
let task = NSTask()
task.launchPath = "/usr/local/bin/some_app"
task.arguments = ["one", "two", "thwee"] // misspelled on purpose, syntax error
let pipe = NSPipe()
task.standardOutput = pipe
task.launch()
task.waitUntilExit()
if (task.terminationStatus != 0) {
// whine loudly
....
}