Re: NSScanner off-by-one and I can't see why...
Re: NSScanner off-by-one and I can't see why...
- Subject: Re: NSScanner off-by-one and I can't see why...
- From: Alastair Houghton <email@hidden>
- Date: Thu, 30 Apr 2009 13:10:47 +0100
On 30 Apr 2009, at 12:45, Graham Cox wrote:
The result for the above string should be keys @"city", @"state",
@country" with ranges {0,6}, {7,7} and {15,9} respectively. The
ranges include the delimiter characters while the keys do not. The
results I actually get are correct keys, but ranges {0,6}, {6,7} and
{14,9}. The spaces don't appear to have been counted, but I'm
unclear why that is.
Anyone spot my mistake?
You need
[scanner setCharactersToBeSkipped:nil];
If you look at -scanUpToString:intoString:'s docs, you'll see that it
says that it returns NO (implying that it didn't scan any characters)
if the only scanned characters are in the to-skip character set.
Kind regards,
Alastair.
--
http://alastairs-place.net
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden