You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It looks like you're scanning up to the symbol character set, and then assuming that the symbol part of the scanned string has at least 2 characters:
NSString *word=[read substringWithRange:NSMakeRange(idx, 2)];
I fixed this with the following code:
int charactersToRead = MIN( 2, read.length );
NSString *word=[read substringWithRange:NSMakeRange(idx, charactersToRead)];
But then I found a different bug, where a sentence with a symbol in the middle, like the example above, loses it's space. NSScanners by default have whitespace and newline characters set in charactersToBeSkipped. So in the example string above, after the crash fix, your code scans in "Image ", then "|", then in the second iteration ,the "scanUpToCharactersFromSet" will ignore the " " at the beginning of the remaining string (" Code"). This is all fixed by doing this:
NSScanner *s = [NSScanner scannerWithString:self.text];
[s setCharactersToBeSkipped: nil];
But now, there's a 3rd bug, where it assumes that "words" are separated by spaces. Hence, in a string like this:
@"This is a #test-||-with some symbols."
It is rendered as:
This is a #test- ||-with some symbols.
(Note the extra space between #test- and ||). I don't see an easy way to fix this without re-writing most of this code, so I'll leave it to you. Happy to do a pull request if you care.
The following string:
@"Image | Code"
causes the label to crash. Am testing a fix right now.
The text was updated successfully, but these errors were encountered: