Chapter 13. Using Scripts Within Applications

With Mac OS X's large variety of scripting languages, each with its own strengths and application domain, there are often times when you will want to leverage them in your Cocoa applications. The best solution to certain problems may not be Objective-C and Cocoa, but may be a script. At the same time, you don't want to subject your users to the script directly, or the command-line interface—you want the features offered by the scripting language, in a user-friendly Cocoa graphical user interface (GUI). Luckily, Cocoa provides plenty of ways to leverage a script or command-line tool from within a Cocoa program.

In this chapter you learn

  • The C functions that you can use to run external scripts and programs

  • Which Cocoa classes can aid you to run external scripts and programs, including NSTask, NSFileManager, NSFileHandle, NSBundle, and NSPipe

  • How to pass data to and retrieve data from an external program or script, from within a Cocoa application

  • How to run external programs synchronously and asynchronously from within a Cocoa application

Get Beginning Mac OS® X Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.