Run a terminal command in a Mac app with Swift Xcode
问题 I am trying to run a terminal command in a Mac app that I am developing. The terminal command is: sudo sysctl -w net.inet.tcp.delayed_ack=0 I have tried using NSTask but it seems that I am doing something wrong every time. I just want to run this command and print the output. Thank you for your attention. PS. here is what my current code looks like (thanks to your replies): let task = NSTask() task.launchPath = "/usr/sbin/sysctl" task.arguments = ["-w", "net.inet.tcp.delayed_ack=0"] let pipe