I'm making a console-based application in Objective-C which relies on being able to clear the console periodically. How can this be done? All I've seen on SO and Google were ways to have the developer clear the console with X-Code, but that will not do.
One solution I found on Yahoo! Answers told me to do the following, but it does not run due to being unable to find a file:
NSTask *task;
task = [[NSTask alloc]init];
[task setLaunchPath: @"/bin/bash"];
NSArray *arguments;
arguments = [NSArray arrayWithObjects: @"clear", nil];
[task setArguments: arguments];
[task launch];
[task waitUntilExit];
Try using :
system( "clear" );
Important headers :
#include <stdlib.h>
Hint : Objective-C is still C, right?
UPDATE :
In case of a "TERM environment variable not set." error :
1) Run the program, directly from your terminal (or just ignore the error while testing it in Xcode; it's supposed to run in a normal terminal anyway, huh?)
2) Set the TERM variable in your Scheme's settings. To what? Just run this in your terminal to see what "TERM" should be :
DrKameleons-MacBook-Pro:Documents drkameleon$ echo $TERM
xterm-256color
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With