• 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: Gustavo Pizano <email@hidden>
  • Date: Sat, 4 Apr 2009 14:06:42 +0200

Hello, Im gonna check what Quencey Morris, suggested, Im gonna see how to stop just before the line break, and analyze the data I gather, I think NSScanner provides me a quick way to scan the file lines, its huge, so checking line by line it will take longer.

When reading the documentation I read that by default NSScanner sips blanks and line breaks, so I will see how to change that behavior,.

If I have no success in doing so I will be posting again.

Thanks a lot for the help

Gustavo



On 4.4.2009, at 13:32, Kirk Kerekes wrote:

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


References: 
 >RE: Best Practice for reading a string with NSScanner (From: Kirk Kerekes <email@hidden>)

  • Prev by Date: Need localization-proof method of transporting dates.
  • Next by Date: Re: Need localization-proof method of transporting dates.
  • Previous by thread: RE: Best Practice for reading a string with NSScanner
  • Next by thread: best practice for dealing with saving/loading preferences.
  • Index(es):
    • Date
    • Thread