Instance Method

insert(_:at:)

Inserts into the receiver the characters of a given string at a given location.

Declaration

func insert(_ aString: String, at loc: Int)

Parameters

aString

The string to insert into the receiver. aString must not be nil.

anIndex

The location at which aString is inserted. The location must not exceed the bounds of the receiver.

Discussion

The new characters begin at anIndex and the existing characters from anIndex to the end are shifted by the length of aString.

This method treats the length of the string as a valid index value that returns an empty string.

See Also

Modifying a String

func append(String)

Adds to the end of the receiver the characters of a given string.

func applyTransform(StringTransform, reverse: Bool, range: NSRange, updatedRange: NSRangePointer?)

Transliterates the receiver by applying a specified ICU string transform.

func deleteCharacters(in: NSRange)

Removes from the receiver the characters in a given range.

func replaceCharacters(in: NSRange, with: String)

Replaces the characters from aRange with those in aString.

func replaceOccurrences(of: String, with: String, options: NSString.CompareOptions = [], range: NSRange)

Replaces all occurrences of a given string in a given range with another given string, returning the number of replacements.

func setString(String)

Replaces the characters of the receiver with those in a given string.