Instance Method


Replaces the characters in the given range with the characters of the given string.


func replaceCharacters(in range: NSRange, with str: String)



A range specifying the characters to replace.


A string specifying the characters to replace those in aRange.


The new characters inherit the attributes of the first replaced character from aRange. Where the length of aRange is 0, the new characters inherit the attributes of the character preceding aRange if it has any, otherwise of the character following aRange.

Raises an rangeException if any part of aRange lies beyond the end of the receiver’s characters.

See Also

Changing characters

func deleteCharacters(in: NSRange)

Deletes the characters in the given range along with their associated attributes.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software