Answer the question
In order to leave comments, you need to log in
How to count a string in objective-c?
Hello!
Here in C++, using cin.getline() you can read lines with a space.
But as I understand it, in the objective-c language there is only scanf () , which can only count 1 word.
What object then to read out lines?
Answer the question
In order to leave comments, you need to log in
It became interesting and decided to google "Objective-C console readline" and somewhere in the 6th place I found what I was looking for =) I tested it and everything works. Hold =)
NSLog(@"type a text:\n");
NSFileHandle *input = [NSFileHandle fileHandleWithStandardInput];
NSData *inputData = [input availableData];
NSString *str = [[NSString alloc] initWithData:inputData encoding:NSUTF8StringEncoding];
NSLog(@"Text: %@", str);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question