尽管问题本身是微不足道的(忘记了路径),但在其他人需要相同功能的情况下,我还是留下了疑问。
let path = NSBundle.mainBundle().resourcePath!.stringByDeletingLastPathComponent.stringByDeletingLastPathComponentlet task = NSTask()task.launchPath = "/usr/bin/open"task.arguments = [path]task.launch()exit(0)
编辑 (Sw3的每日Swift语法更改; Sw4也适用):
let url = URL(fileURLWithPath: Bundle.main.resourcePath!)let path = url.deletingLastPathComponent().deletingLastPathComponent().absoluteStringlet task = Process()task.launchPath = "/usr/bin/open"task.arguments = [path]task.launch()exit(0)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)