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

Best Practice for reading a string with NSScanner


  • Subject: Best Practice for reading a string with NSScanner
  • From: Gustavo Pizano <email@hidden>
  • Date: Fri, 3 Apr 2009 21:08:52 +0200

Hello, this is another post form a previous one that I was able to solve, but this one has to be more with a efficient method to achieve the following goal.

I have a text file, which contains bunch of lines like this ones : (sorry about the identation)
apphelp.dll 5.1.2600.5512 Application Compatibility Client Library
appmgmts.dll 5.1.2600.5512 Software installation Service
appmgr.dll 5.1.2600.5512 Software Installation Snapin Extenstion
asferror.dll 11.0.5721.5145 Definice chyb ASF
asycfilt.dll 5.1.2600.5512
ati2cqag.dll 6.14.10.233 Central Memory Manager / Queue Server Module
ati2dvaa.dll 6.13.10.5019 ATI RAGE 128 WindowsNT Display Driver
divxwmpexttype.dll



So I was doing scanning the string (which came from the file) reading the library name and saving the result into productName, then the version and then the description, then Im reading an empty string to put the scanner on the next line,

[theScanner scanUpToString:@" " intoString:&productName];
[theScanner scanString:@"" intoString:NULL];
[theScanner scanUpToString:@" " intoString:&version];
[theScanner scanString:@"" intoString:NULL];
[theScanner scanUpToString:@" " intoString:&des];
[theScanner scanString:@"" intoString:NULL];


All the above in a while loop.
BUT!, here is where it got weird for me. the file is not consistent on each road, as you can see the line that contains the asycfilt.dll has a version, but has no description, so when running the loop, after it successfully scan the previous road, start scanning this particular line, gets the library name, then the version, and in the status will get the next library name, which its wrong, also it will happen something similar with the last library name, which contains no version and no description, in this case in &version will put the next library name(which is in the next line, I didn't put it), and the description will be the version of the last library name.


I have tried many things, but no success, I have getting the NScharacterset for a line break, and try to read until there, but its always doing the same thing, i guess im not using it properly. , I have tried putting some conditionals to see what I have just scanned, but as you can see all data its different from each other.

The last "hope" I have is to compare the next scanned value to see if the string I have just scanned has a suffix of .dll in that case I know Im in the next line, but im sure there should be some workaround different than this one.


Any help I will really appreciate it.

Thanks a lot

Gustavo





_______________________________________________

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: Quincey Morris <email@hidden>
  • Prev by Date: RE: IB Plugin help
  • Next by Date: Re: Toll-free bridge type at runtime
  • Previous by thread: Re: IB Plugin help
  • Next by thread: Re: Best Practice for reading a string with NSScanner
  • Index(es):
    • Date
    • Thread