RE: Best Practice for reading a string with NSScanner
RE: Best Practice for reading a string with NSScanner
- Subject: RE: Best Practice for reading a string with NSScanner
- From: Kirk Kerekes <email@hidden>
- Date: Sat, 4 Apr 2009 06:32:58 -0500
It looks like you have tabular data to deal with, like punch cards.
That means that you can assume a fixed character position for the
beginning of each column in the table. And your code can infer those
positions the same way you would -- by looking at the source file. Or
you can just manually determine the offsets. Note that the end of
column[1] is the beginning of column[2]-1, and so on.
First, steal <http://thotzy.com/THOTZY/lines.html> to break your big
NSString into an array of lines.
Then take each line and use substringWithRange to extract the field
text for each column, then use [NSString
stringByTrimmingCharactersInSet:] to trim the field to just the text
contents.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden