0

I'm making a free Mac app that is simply a wrapper over the "purge" command that can be run in Terminal. I'm tired of the ripoffs that are populating the Mac App Store and I just want to help people. I've got the GUI finished I just can't figure out how to run the command successfully.

I know I need to use NSTask, but I'm probably not doing it correctly.

NSTask *task = [[NSTask alloc] init];
[task setLaunchPath:@"/bin/sh"];
[task setArguments:[NSArray arrayWithObjects:@"Purge", nil]];
[task launch];

How can I fix this?

Yep
  • 653
  • 5
  • 20

1 Answers1

3

The purge executable is in /usr/bin, so:

NSTask *task = [[NSTask alloc] init];
[task setLaunchPath:@"/usr/bin/purge"];
[task launch]; 

or, even easier:

[NSTask launchedTaskWithLaunchPath:@"/usr/bin/purge" arguments:[NSArray array]];
highlycaffeinated
  • 19,729
  • 9
  • 60
  • 91