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];
...
精彩评论