• 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: NSScanner problem...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSScanner problem...


  • Subject: Re: NSScanner problem...
  • From: Koen van der Drift <email@hidden>
  • Date: Sun, 3 Aug 2003 08:45:26 -0400

On Sunday, August 3, 2003, at 04:21 AM, Stephan Lichtenauer wrote:


NSString *file = [NSString stringWithContentsOfFile:@"FILE.TXT"];
NSArray *arrayWithLines = [file componentsSeparatedByString:@"\n"];

This should give you an array with one NSString per line.


But only if the linebreaks are \n. This will fail if the text has different type of linebreaks. In the latter case you could use the function - (void)getLineStart:(unsigned *)startIndex end:(unsigned *)lineEndIndex contentsEnd:(unsigned *)contentsEndIndex forRange:(NSRange)aRange. IIRC, there is an example in the archives.


- Koen.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: NSScanner problem... (From: Stephan Lichtenauer <email@hidden>)

  • Prev by Date: Re: NSScanner problem...
  • Next by Date: Re: NSImage -- getting raw bitmap data
  • Previous by thread: Re: NSScanner problem...
  • Next by thread: Re: NSScanner problem...
  • Index(es):
    • Date
    • Thread