NSScanner takes a pointer to an NSString:
NSMutableString *myString;
...
[scanner scanUpToCharactersFromSet:charSet intoString:&myString];
[myString appendString:@"hello"];
But myString is mutable, so I get an error when I try to do an append later, saying I’m trying to mutate an un-mutatable.
Do I have to create temp copies and go back&forth, or is there a more efficient way to do this?
Either do
or better: see the next code snippet
In the second approach you will have the inconsistency that for a short while a NSMutable typed variable will hold a immutable string. tis is definitely a flaw. Solution one is much cleaner. If you favor two you should introduce a second NSString variable and pass that to the scanner an d than mutable copy that to your NSMutableString.