Mac OS X coding

Wrapping a CLI with Cocoa

March 14, 2007 · Leave a Comment

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

 

 

 

Categories: NSTask

0 responses so far ↓

  • There are no comments yet...Kick things off by filling out the form below.

Leave a Comment