Re: Slice a .txt file in lines
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