O'Reilly logo

Cocoa® Programming for Mac® OS X, Fourth Edition by Aaron Hillegass, Adam Preble

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 36. NSTask

Each application that you have created is a directory, and somewhere down in that directory is an executable file. To run an executable on a Unix machine, like your Mac, a process is forked, and the new process executes the code in that file. Many executables are command-line tools, and some are quite handy. This chapter, then, will be showing you how to run command-line tools from your Cocoa application by using the class NSTask.

NSTask is an easy-to-use wrapper for the Unix functions fork() and exec(). You give NSTask a path to an executable and launch it. Many processes read data from standard-in and write to standard-out and standard-error. Your application can use NSTask to attach pipes to carry data to and from the external ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required