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

NSScanner behavior


  • Subject: NSScanner behavior
  • From: Ibrahim Bulut <email@hidden>
  • Date: Tue, 11 May 2004 22:36:11 +0200

Hi there,

It seems like when there is no data between fields, eg.
"field1;field2;field3;;;;;field8" NSScanner only recognise field1,
field2, field3 and field8 and skip the empty fields. Is this a bug? or
more important is there a workaround?

I've implemented NSScanner like this:

NSCharacterSet *tabSet;
NSScanner *theScanner;
NSString *scannedItem;

tabSet = [NSCharacterSet characterSetWithCharactersInString:@"\t"];
theScanner = [NSScanner scannerWithString:theData];

while ([theScanner isAtEnd] == NO)
{
if ([theScanner scanUpToCharactersFromSet:tabSet
intoString:&scannedItem])
{
switch (i)
{
// collect items
}

if (i == 10)
{
// insert data to array
i = 0;
}

i++;
}
}


The idea is that I know that there is 11 fields that I collect in the
loop, insert into an array and start over again until NSScanner stops.
I have removed some code for clarity.

Thanks for any suggestions or ideas :)

/Ibrahim

Somewhere in Texas... a village is missing their idiot.
_______________________________________________
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:
    • RE: NSScanner behavior
      • From: "Jonathan E. Jackel" <email@hidden>
  • Prev by Date: CFShow in Cocoa
  • Next by Date: Re: [Array writeToFile:Path atomically:YES]
  • Previous by thread: Re: CFShow in Cocoa
  • Next by thread: RE: NSScanner behavior
  • Index(es):
    • Date
    • Thread