• 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: multiple componentsSeparatedByString
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: multiple componentsSeparatedByString


  • Subject: Re: multiple componentsSeparatedByString
  • From: Jonathan Jackel <email@hidden>
  • Date: Sun, 24 Nov 2002 18:04:43 -0500

> I am trying this now, but run in some problems. Here's a snippet:


Scanners are a bit weird. You need to "scanUpTo" to scan past the undesired
part of the string, and then scan the characters. I think this will work.


while (! [scanner isAtEnd])
{
if ([scanner scanUpToCharactersFromSet: stopSet intoString:nil] &&
[scanner scanCharactersFromSet:stopSet intoString:&result])
{
[anArray addObject:result];
}
}

Also, your e-mail has this code:

> stopSet = [NSCharacterSet characterSetWithCharactersInString:@"ABC];

You need a closing quote mark after the string.

> I found another solution. Instead of using an NSScanner, I just extract
> each character from the string and test it against the NSCharacterSet:

That method works for this particular test, but your original question dealt
with interpreting a file with several different field separators at once.
Scanners, notwithstanding their weirdness, are tailor-made for this. With
your "string" method you'll need to have a way to track the range of the
actual data, rather than the field separators. It's very doable, of course,
but I think a scanner would be a lot better.

Jonathan
_______________________________________________
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.

  • Follow-Ups:
    • NSScanner (was Re: multiple componentsSeparatedByString)
      • From: Koen van der Drift <email@hidden>
    • Re: multiple componentsSeparatedByString
      • From: Koen van der Drift <email@hidden>
References: 
 >RE: multiple componentsSeparatedByString (From: Koen van der Drift <email@hidden>)

  • Prev by Date: Re: getting information on disk usage
  • Next by Date: Quick Q
  • Previous by thread: RE: multiple componentsSeparatedByString
  • Next by thread: Re: multiple componentsSeparatedByString
  • Index(es):
    • Date
    • Thread