Re: getLineStart:end:contentsEnd:forRange:
Re: getLineStart:end:contentsEnd:forRange:
- Subject: Re: getLineStart:end:contentsEnd:forRange:
- From: Ali Ozer <email@hidden>
- Date: Tue, 10 Jul 2001 14:48:00 -0700
>
I take the output of an NSTask in a NSString. Now I'd like to divide it
>
into lines. Id'l like to use the getLineStart:end:contentsEnd:forRange:.
>
Can anyone explain me how the getLineStart:end:contentsEnd:forRange:
>
works and specially what is the aRange parameter (and the other
>
parameters too)?
The answer can be found at:
http://developer.apple.com/techpubs/macosx/Cocoa/Reference/Foundation/ObjC_classic/
Classes/NSString.html#//apple_ref/occ/instm/NSString/getLineStart:end:contentsEnd:
forRange:
getLineStart:end:contentsEnd:forRange:
+ (void)getLineStart:(unsigned *)startIndex
end:(unsigned *)lineEndIndex
contentsEnd:(unsigned *)contentsEndIndex
forRange:(NSRange)aRange
Returns by reference the indexes of the smallest range of lines
containing aRange. A line is delimited by any of these characters, the
longest possible sequence being preferred to any shorter:
* U+000D (\r or CR)
* U+2028 (Unicode line separator)
* U+000A (\n or LF)
* U+2029 (Unicode paragraph separator)
* \r\n, in that order (also known as CRLF)
When this method returns, startIndex contains the index of the first
character of the line, which is at or before the location of aRange;
lineEndIndex contains the index of the first character past the line
terminator; and contentsEndIndex contains the index of the first
character of the line terminator itself. You may pass a nil pointer for
any of these arguments, in which case the work to compute the value
isn't performed.
You can use the results of this method to construct ranges for lines by
using the start index as the range's location and the difference between
the end index and the start index as the range's length.