Wednesday, April 25, 2012

How do I clear the console in Objective-C

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];

No comments:

Post a Comment