• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Infinite loop in NSScanner
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Infinite loop in NSScanner
      • From: "Mike R. Manzano" <email@hidden>
References: 
 >Infinite loop in NSScanner (From: "Mike R. Manzano" <email@hidden>)

  • Prev by Date: Re: [OT] Job hunting
  • Next by Date: Re: To Framework or to Dylib?
  • Previous by thread: Infinite loop in NSScanner
  • Next by thread: Re: Infinite loop in NSScanner
  • Index(es):
    • Date
    • Thread