How can I get input from the console in Objective C? My concern is to avoid the possibility of buffer overflows, which is why I want to steer clear of gets() and scanf()/sscanf(). From searching StackOverflow, that's all I've been seeing. Is scanf() more secure in Objective C to the extent that I wouldn't have to worry?
Just recently, I found this example: I like it; but is there already a class for such?
printf("What is your name?");
NSFileHandle *input = [NSFileHandle fileHandleWithStandardInput];
NSData *inputData = [NSData dataWithData:[input availableData]];
NSString *inputString = [[NSString alloc] initWithData:inputData
encoding:NSUTF8StringEncoding];
inputString = [inputString stringByTrimmingCharactersInSet:
[NSCharacterSet whitespaceAndNewlineCharacterSet]];
printf("Hello %s.n",[inputString UTF8String]);