• 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: Best Practice for reading a string with NSScanner
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Best Practice for reading a string with NSScanner
      • From: Gustavo Pizano <email@hidden>
  • Prev by Date: Re: Very interesting ordering caveat with NSArray arrayWithObjects:
  • Next by Date: Need localization-proof method of transporting dates.
  • Previous by thread: Re: Best Practice for reading a string with NSScanner
  • Next by thread: Re: Best Practice for reading a string with NSScanner
  • Index(es):
    • Date
    • Thread