Date
1 - 2 of 2
Scanner oddity
Laurent Daudelin
Anybody uses the Scanner class?
I’m using an instance to extract some data from a string received from a web server.
If I have a string that is “45\nBlah”, read the “45”, the scanner location is just before the carriage return. If I then try a someString = scanner.scanString(“\nBlah”), someString is nil. But if I do scanner.scanLocation += 1, then someString = scanner.scanString(“Blah”), then someString contains “Blah”. Not sure if I’m using it correctly or if there is some kind of a bug.
By the way, speaking of “scanLocation”, the editor gives me a warning that it’s been deprecated as of iOS 13. But when I open the documentation about the Scanner, there is no mention that it’s been deprecated. Further, the editor doesn’t suggest a replacement.
Sandor Szatmari
Laurent,
On Sep 29, 2021, at 15:11, Laurent Daudelin <laurent@...> wrote:
Anybody uses the Scanner class?I’m using an instance to extract some data from a string received from a web server.If I have a string that is “45\nBlah”, read the “45”, the
Have you tried -setCharactersToBeSkipped:
Set that to skip new line, carriage return…
Maybe that will work for you?
Sandor
scanner location is just before the carriage return. If I then try a someString = scanner.scanString(“\nBlah”), someString is nil. But if I do scanner.scanLocation += 1, then someString = scanner.scanString(“Blah”), then someString contains “Blah”. Not sure if I’m using it correctly or if there is some kind of a bug.By the way, speaking of “scanLocation”, the editor gives me a warning that it’s been deprecated as of iOS 13. But when I open the documentation about the Scanner, there is no mention that it’s been deprecated. Further, the editor doesn’t suggest a replacement.