I'm developing a simple game in Objective-C (iOS) and Xcode. I built the MVC pattern but I'd like my view to be just the console by now, in order to print output data (I will take care of graphics and views later). However, I'm having some troubles with user input to test game logics. Apparently functions like scanf or
- (NSString *) getInput()
{
NSFileHandle *input = [NSFileHandle fileHandleWithStandardInput];
NSData *inputData = [input availableData];
NSString *inputString = [[NSString alloc] initWithData: inputData encoding:NSUTF8StringEncoding];
inputString = [inputString stringByTrimmingCharactersInSet: [NSCharacterSet newlineCharacterSet]];
return inputString;
}
dont work. The program does not stop and wait for input but instead goes on and leaves the variable empty. Is there any other solution? Am I doing something wrong? Thanks