Instance Method

getCharacters(_:range:)

Copies characters from a given range in the receiver into a given buffer.

Declaration

func getCharacters(_ buffer: UnsafeMutablePointer<unichar>, range: NSRange)

Parameters

buffer

Upon return, contains the characters from the receiver. buffer must be large enough to contain the characters in the range aRange (aRange.length*sizeof(unichar)).

aRange

The range of characters to retrieve. The range must not exceed the bounds of the receiver.

Discussion

This method does not add a NULL character.

The abstract implementation of this method uses character(at:) repeatedly, correctly extracting the characters, though very inefficiently. Subclasses should override it to provide a fast implementation.

You should always use the rangeOfComposedCharacterSequence(at:) or rangeOfComposedCharacterSequences(for:) method to determine character boundaries, so that any surrogate pairs or character clusters are handled correctly.

See Also