A dynamic plain-text Unicode string object.
SDKs
- iOS 2.0+
- macOS 10.0+
- Mac Catalyst 13.0+
- tvOS 9.0+
- watchOS 2.0+
Framework
- Foundation
Declaration
@interface NSMutableString : NSString
Overview
The NSMutable
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 NSMutable
class adds one primitive method—replace
—to the basic string-handling behavior inherited from NSString
. All other methods that modify a string work through this method. For example, insert
simply replaces the characters in a range of 0
length, while delete
replaces the characters in a given range with no characters.
NSMutableString is “toll-free bridged” with its Core Foundation counterpart, CFMutable
. See Toll-Free Bridging for more information.