I have a character set; I've tried both
NSCharacterSet *newlineSet = [NSCharacterSet
characterSetWithCharactersInString:@"\n"];
and
NSCharacterSet *newlineSet = [NSCharacterSet newlineCharacterSet];

     I use this to read lines from a file, like so:
while ([scanner scanUpToCharactersFromSet:newlineSet
intoString:&currentRecord]) {}

     I then read out substrings from currentRecord like so:
someNumber = [NSNumber numberWithInt:[[currentRecord
substringWithRange:NSMakeRange(0, 6)] intValue]];
someOtherNumber = [[currentRecord substringWithRange:NSMakeRange(14, 2)]
intValue];

     The file looks like:
"   455| | | 3| 1|  \n118222| |P| 2| 1|  "

     The issue is, someNumber always is the correct number, but
someOtherNumber is not;  it is always zero.  If I use an NSString, I
see that it is being set to two spaces (the last two spaces in the
record).  For the second record, both are correct.  So it appears
that the first three spaces in the first record are being ignored. 
This is confirmed by printing the length of each record; the first
record is three shorter.

     Does anyone have any idea why this is going on?  The trailing spaces
are being counted correctly.



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to