开发者

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

开发者 https://www.devze.com 2023-02-11 10:05 出处:网络
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

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

精彩评论

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