开发者

How to run the "Purge" command through NSTask?

开发者 https://www.devze.com 2023-03-22 00:47 出处:网络
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 peopl

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

精彩评论

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

关注公众号