Wrapping a CLI with Cocoa

Using the NSTask method enables one to create a GUI wrapper around a commandline program. For instance, this code snippet derived from CocoaDev shows how to launch the ls utility:

NSTask *task;

task = [[NSTask alloc] init];
[task setLaunchPath: @”/bin/ls”];

NSArray *arguments;
arguments = [
NSArray arrayWithObjects: @”-l”, @”-a”, @”-t”,nil];
[task setArguments: arguments];

 

 

 

Advertisements

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