Re: Infinite loop in NSScanner
Re: Infinite loop in NSScanner
- Subject: Re: Infinite loop in NSScanner
- From: Prachi Gauriar <email@hidden>
- Date: Wed, 23 Mar 2005 18:08:50 -0500
On Mar 23, 2005, at 5:37 PM, Mike R. Manzano wrote:
Why does an input string containing a comma or semicolon cause this to
go into an infinite loop, yet works when only spaces are used to
delimit keywords?
<snip>
while( ![scanner isAtEnd] ) {
[scanner scanUpToCharactersFromSet:whitespaceSet
intoString:&scanString];
[keywordArray addObject:scanString];
NSLog( @"*" ) ;
}
Your problem is that you only scan up to characters in the whitespace
set. You never actually scan them in. After you scan up to them, be
sure to send scanner the -scanCharactersFromSet:intoString: messge to
pick up those extra characters. You'll probably want to add:
[scanner scanCharactersFromSet:whitespaceSet intoString:nil];
-Prachi
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden