开发者

Foundation program,Is there any function which can clear the terminal in Objective-c or cocoa

Command Line Programming

开发者_开发技巧Any function in Cocoa like

system("cls")

in C?

Thanks.


While in Xcode, there is no command to clear the output window (it's not really a terminal, so it doesn't behave like one and won't clear - when you try to clear you'll see "TERM variable not set..."). However, if you run your program in the Terminal, you can use system("clear") if you wish to clear the screen, or you can use NSTask to avoid calling system:

...
NSTask *clearScreen = [NSTask launchedTaskWithLaunchPath:@"/usr/bin/clear" arguments:[NSArray array]];
[clearScreen waitUntilExit];
...
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜