This chapter has introduced you to ways of running external programs and scripts from a Cocoa application. You learned the following:
That you can use the C functions system and popen to run commands and short scripts from inside C and Objective-C programs
That you can communicate with subprocesses started with system via environment variables and temporary files, and that subprocesses started in this manner share the standard input and output streams of the parent process
The difference between synchronous and asynchronous functions, and that system is a synchronous function and popen is asynchronous
That the Cocoa class NSTask is more powerful than system or popen, allowing you to pass arguments to a subprocess, set its environment separately to the parent process, and set its standard input and output streams
That NSTask runs asynchronously, and that the notification NSTaskDidTerminateNotification is posted whenever a subprocess exits
About the class NSPipe, and that you can use it to avoid temporary files when passing data to, and retrieving data from, a subprocess started with NSTask
The exercise that follows tests your understanding of the material covered in this chapter. You can find the solution in the appendix.