DekGenius.com
[ Team LiB ] Previous Section Next Section

NSTask Mac OS X 10.0

This class provides an interface for an application to execute other programs as subprocesses. To create an NSTask, use alloc and init. Before a task can be executed, it must be prepared. By default a task inherits the environment of its parent process, which includes attributes such as the current working directory. To specify what program the task should execute, set the launch path of the program in the task using the method setLaunchPath:. Arguments for the executable are provided in an NSArray through the method setArguments:. If you need to pass data to a task and receive data in return, connect an NSPipe or NSFileHandle object to the executable's standard input, output, or error using setStandardInput:, setStandardOutput:, and setStandardError:, respectively.

To execute a task, invoke the method launch. NSTask also provides methods for controlling the execution of a task through the methods interrupt, suspend, terminate, and resume.

figs/cocn_13108.gif

@interface NSTask : NSObject
 // Initializers
   - (id)init;
 // Accessor Methods
   - (void)setStandardInput:(id)input;
   - (id)standardInput;
   - (void)setLaunchPath:(NSString *)path;
   - (NSString *)launchPath;
   - (void)setEnvironment:(NSDictionary *)dict;
   - (NSDictionary *)environment;
   - (void)setCurrentDirectoryPath:(NSString *)path;
   - (NSString *)currentDirectoryPath;
   - (void)setStandardOutput:(id)output;
   - (id)standardOutput;
   - (void)setStandardError:(id)error;
   - (id)standardError;
   - (void)setArguments:(NSArray *)arguments;
   - (NSArray *)arguments;
 // Class Methods
   + (NSTask *)launchedTaskWithLaunchPath:(NSString *)path arguments:(NSArray *)arguments;
 // Instance Methods
   - (void)interrupt;
   - (void)launch;
   - (BOOL)isRunning;
   - (int)processIdentifier;
   - (BOOL)resume;
   - (BOOL)suspend;
   - (void)terminate;
   - (int)terminationStatus;
   - (void)waitUntilExit;

    [ Team LiB ] Previous Section Next Section