• 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: NSScanner stoopid question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSScanner stoopid question


  • Subject: Re: NSScanner stoopid question
  • From: Koen van der Drift <email@hidden>
  • Date: Mon, 7 Apr 2003 09:44:51 -0400

At 11:36 AM -0500 4/5/03, Jonathan Jackel wrote:
On Friday, April 4, 2003, at 09:34 PM, Koen van der Drift wrote:

Hi,

I am scanning a string for a specific character. However, if the next
character belongs to another NSCharacterSet, I should not continue with the
algorithm.

Here's a snippet:


NSScanner *scanner = [NSScanner scannerWithString: myString];
int len = [myString length];
int current;

while (![scanner isAtEnd])
{
[scanner scanUpToCharactersFromSet: firstSet intoString:nil];

current = [scanner scanLocation];

if ( len != current + 1 )
{
if ( ![restrictionSet characterIsMember:
[myString characterAtIndex: current + 1 ]])
{
...
}
}
}

I think what you want is if(len > current +1)



Yes, thanks,

And I also need to add a [scanner setScanLocation:current + 1], otherwise the scanner will never advance after afirst match.

- Koen.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: List all installed applications in Mac OSX using Cocoa.
  • Next by Date: Re: custom NSRulerView and other related issues
  • Previous by thread: NSScanner stoopid question
  • Next by thread: NSMovieView's controller is greyed out
  • Index(es):
    • Date
    • Thread