Coding a command-line tool in Objective-C that takes inputs, clears screen and then outputs Coding a command-line tool in Objective-C that takes inputs, clears screen and then outputs unix unix

Coding a command-line tool in Objective-C that takes inputs, clears screen and then outputs


This is possible. Use the "Command Line Tool" template in Xcode when you create your project.

A quick example could be:

#import <Foundation/Foundation.h>int main (int argc, const char * argv[]){    @autoreleasepool {        char input[50];        while (true) {            // take the argument as an NSString            NSLog(@"Enter some text please: ");            fgets(input, sizeof input, stdin);            NSString *argument = [[NSString stringWithCString:input encoding:NSUTF8StringEncoding] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];            // do something with the NSString.            NSString *uppercase = [argument uppercaseString];            // clear the terminal screen.            system("clear");            // output the manipulated screen.            NSLog(@"Hello, %@!", uppercase);        }    }    return 0;}