How can I run a shell command from my Cocoa app?

cocoa, shell, terminal

Solution

Use an `NSTask`. http://www.cocoadev.com/index.pl?NSTask

Problem

I want to run a simple command from my Cocoa app through code, NOT creating a shell script and running it that way, but by running it through the application, being able to define everything and change it on the fly.

Original source