Instance Method

getParagraphStart(_:end:contentsEnd:for:)

Returns by reference the beginning of the first paragraph and the end of the last paragraph touched by the given range.

Declaration

func getParagraphStart(_ startPtr: UnsafeMutablePointer<Int>?, end parEndPtr: UnsafeMutablePointer<Int>?, contentsEnd contentsEndPtr: UnsafeMutablePointer<Int>?, for range: NSRange)

Parameters

startIndex

Upon return, contains the index of the first character of the paragraph containing the beginning of aRange. Pass NULL if you do not need this value (in which case the work to compute the value isn’t performed).

endIndex

Upon return, contains the index of the first character past the terminator of the paragraph containing the end of aRange. Pass NULL if you do not need this value (in which case the work to compute the value isn’t performed).

contentsEndIndex

Upon return, contains the index of the first character of the terminator of the paragraph containing the end of aRange. Pass NULL if you do not need this value (in which case the work to compute the value isn’t performed).

aRange

A range within the receiver. The value must not exceed the bounds of the receiver.

Discussion

A paragraph is any segment of text delimited by a carriage return (U+000D), newline (U+000A), or paragraph separator (U+2029).

If aRange is contained with a single paragraph, of course, the returned indexes all belong to that paragraph. Similar to getLineStart(_:end:contentsEnd:for:), you can use the results of this method to construct the ranges for paragraphs.

See Also

Determining Line and Paragraph Ranges

func getLineStart(UnsafeMutablePointer<Int>?, end: UnsafeMutablePointer<Int>?, contentsEnd: UnsafeMutablePointer<Int>?, for: NSRange)

Returns by reference the beginning of the first line and the end of the last line touched by the given range.

func lineRange(for: NSRange)

Returns the range of characters representing the line or lines containing a given range.

func paragraphRange(for: NSRange)

Returns the range of characters representing the paragraph or paragraphs containing a given range.