开发者

How to run the "Purge" command through NSTask?

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 开发者_StackOverflowcorrectly.

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

How can I fix this?


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜