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

NSScanner problem


  • Subject: NSScanner problem
  • From: Paul Ferguson <email@hidden>
  • Date: Fri, 23 Nov 2001 07:32:01 -0800
  • Resent-date: Mon, 26 Nov 2001 11:01:30 -0800
  • Resent-from: Paul Ferguson <email@hidden>
  • Resent-message-id: <email@hidden>
  • Resent-to: email@hidden

I have been unable to resolve a problem I'm having with NSScanner.

I have a string like this:

NSString * foo = @"1 2 \"three\"\"four\"";

which I want to scan into two ints and two NSStrings:

NSScanner scanner = [[NSScanner alloc] initWithString: foo];
[scanner scanInt: &i1];
[scanner scanInt: &i2];
[scanner scanUpToString: @"\"" intoString: nil]; // <-- here is the problem
[scanner setScanLocation: [scanner scanLocation]+1];
[scanner scanUpToString: @"\"" intoString: &s3];
[scanner setScanLocation: [scanner scanLocation]+1];
[scanner scanUpToString: @"\"" intoString: nil];
[scanner setScanLocation: [scanner scanLocation]+1];
[scanner scanUpToString: @"\"" intoString: &s4];

The problem is that the scanUpToString:intoString: method never moves the scanner's scanLocation, it remains where it was after the second scanInt: call. It seems that scanUpToString:intoString: should change the scan location, which it does if you substitute another string for @"\"" in my example (regardless of whether that string occurs in foo.)

I've tried using scanUpToCharactersFromSet:intoString: as well, and it makes no difference.

Thanks,

<fergy/>


  • Follow-Ups:
    • Re: NSScanner problem
      • From: Drew McCormack <email@hidden>
  • Prev by Date: Re: NSSmallControlSize in programatically creating an NSPopUpButtonCell?
  • Next by Date: drawing pixels in NSView
  • Previous by thread: Fwd: Documenting Obj-C code
  • Next by thread: Re: NSScanner problem
  • Index(es):
    • Date
    • Thread