• 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: Slice a .txt file in lines
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Slice a .txt file in lines


  • Subject: Re: Slice a .txt file in lines
  • From: Andreas Mayer <email@hidden>
  • Date: Tue, 20 Jun 2006 14:38:54 +0200


Am 20.06.2006 um 08:11 Uhr schrieb Ben Lachman:

particularly componentsSeparatedByString: is useful for splitting files by line endings.

Not really, since there is more than one line ending character. Try this one instead:


- (NSArray *)componentsSeparatedByLineDelimiter
{
NSMutableArray *result = [[[NSMutableArray alloc] init] autorelease];
unsigned start;
unsigned end;
unsigned next;
unsigned stringLength;
NSRange searchRange;
NSRange lineRange;

stringLength = [self length];
searchRange = NSMakeRange(0, 0);
do {
[self getLineStart:&start end:&next contentsEnd:&end forRange:searchRange];
lineRange.location = start;
lineRange.length = end-start;
[result addObject:[self substringWithRange:lineRange]];
searchRange.location = next;
} while (next < stringLength);
return result;
}



Andreas _______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: Slice a .txt file in lines
      • From: Sean Murphy <email@hidden>
References: 
 >Slice a .txt file in lines (From: Neto <email@hidden>)
 >Re: Slice a .txt file in lines (From: Ben Lachman <email@hidden>)

  • Prev by Date: Re: Getting average power / peak power (sound monitoring)
  • Next by Date: Help needed with the key down event in NSTextField
  • Previous by thread: Re: Slice a .txt file in lines
  • Next by thread: Re: Slice a .txt file in lines
  • Index(es):
    • Date
    • Thread