Wrapping a CLI with Cocoa–Final Comments

Update: I have found a better way. See this post.

So, probably the easiest way (even if somewhat pokey) to wrap a CLI program with a Cocoa GUI is to use AppleScript as the bridge. For example:

do shell script “cd /Xcode_projects/Debug; ./sample > result.txt”

is the contents of a sample applescript, where result.txt is the output of the CLI, sample is the name of the CLI program. One would use NSTask to run the applescript(in order to run the CLI and generate output).

Advertisements

3 responses to “Wrapping a CLI with Cocoa–Final Comments

  1. Even better would be to use NSTask in a separate thread to run NSTask(I have not done this myself, but CocoaDev has some good information on multithreading business).

  2. Great site and interesting reading

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