• 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
reading several lines
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

reading several lines


  • Subject: reading several lines
  • From: Hans van der Meer <email@hidden>
  • Date: Thu, 11 Oct 2007 23:24:39 +0200

I need to read a file containing lines of text. Like this:
abcd
efg
xyz

After some searching of the docs I came up with:

NSString *contents =
[NSString stringWithContentsOfFile: file encoding: NSASCIIStringEncoding error: NULL];


However, this does not seem to read beyond the first line, giving contents = "abcd" and nothing more.
Repeated calling makes no difference, as could be expected. Changing the end of lines to Apple's and the encoding to the MacRoman encoding had no effect.


How do I either repeatedly read the lines? Or all of them at once and scanning the resulting string? Because the text file can become fairly long, the first option could be desirable.

The "String Programming Guide for Cocoa" did not help me further.
Can someone point me in the right direction?

Hans van der Meer



_______________________________________________

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: reading several lines
      • From: H M <email@hidden>
  • Prev by Date: Re: Long Double Calculation on Intel
  • Next by Date: Re: reading several lines
  • Previous by thread: NYC cocoaheads meeting
  • Next by thread: Re: reading several lines
  • Index(es):
    • Date
    • Thread