Using AMShellWrapper for Wrapping Command Line Tools

I have found that AMShellWrapper is very nice for wrapping Command Line Tools. For an example on how to use it, see Andreas Mayer’s code. You might also find my cocoagcalc source code useful.

The key part of using AMShellWrapper is to implement the protocol:



@protocol AMShellWrapperController
// implement this protocol to control your AMShellWrapper object:

- (void)appendOutput:(NSString *)output;
// output from stdout

- (void)appendError:(NSString *)error;
// output from stderr

- (void)processStarted:(id)sender;
// This method is a callback which your controller can use to do other initialization
// when a process is launched.

- (void)processFinished:(id)sender withTerminationStatus:(int)resultCode;
// This method is a callback which your controller can use to do other cleanup
// when a process is halted.

// AMShellWrapper posts a AMShellWrapperProcessFinishedNotification when a process finished.
// The userInfo of the notification contains the corresponding NSTask ((NSTask *), key @"task")
// and the result code ((NSNumber *), key @"resultCode")
// ! notification removed since it prevented the task from getting deallocated

@end
Advertisements

One response to “Using AMShellWrapper for Wrapping Command Line Tools

  1. Pingback: Mac OS X coding Wrapping a CLI with Cocoa–Final Comments «

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s