Executing shell commands with NSTask – Objective-C Cocoa

You could do something like:

NSTask *task = [[NSTask alloc] init];
[task setLaunchPath:@"/bin/bash"];
[task setArguments:@[ @"-c", @"/usr/bin/killall Dock" ]];
[task launch];

Exactly what launch path and arguments you provide are dictated by the command you want to run and its parameters.

Leave a Comment