0

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

1
  • You have to make it wait. Or you could make it look like waiting for input, but as the event comes, it does what is needed. Commented Nov 22, 2014 at 17:47

1 Answer 1

2

There is no such thing as console input in iOS application. If you want to test some game logic - generate data from user inside the app itself.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.