Contents

NSMutableString

A dynamic plain-text Unicode string object.

Declaration

class NSMutableString

Overview

In Swift, you can use this type instead of a String in cases that require reference semantics.

The NSMutableString class declares the programmatic interface to an object that manages a mutable string—that is, a string whose contents can be edited—that conceptually represents an array of Unicode characters. To construct and manage an immutable string—or a string that cannot be changed after it has been created—use an object of the NSString class.

The NSMutableString class adds one primitive method—replaceCharacters(in:with:)—to the basic string-handling behavior inherited from NSString. All other methods that modify a string work through this method. For example, insert(_:at:) simply replaces the characters in a range of 0 length, while deleteCharacters(in:) replaces the characters in a given range with no characters.

NSMutableString is “toll-free bridged” with its Core Foundation counterpart, CFMutableString. See Toll-Free Bridging for more information.

Topics

Creating and Initializing a Mutable String

Modifying a String

Constants

Instance Methods