O'Reilly logo

Beginning Mac OS® X Programming by Drew McCormack, Michael Trent

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 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

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