A dynamic plain-text Unicode string object.


@interface NSMutableString : NSString


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—replaceCharactersInRange:withString:—to the basic string-handling behavior inherited from NSString. All other methods that modify a string work through this method. For example, insertString:atIndex: simply replaces the characters in a range of 0 length, while deleteCharactersInRange: replaces the characters in a given range with no characters.

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


Creating and Initializing a Mutable String

+ stringWithCapacity:

Returns an empty NSMutableString object with initial storage for a given number of characters.

- initWithCapacity:

Returns an NSMutableString object initialized with initial storage for a given number of characters,

Modifying a String

- appendFormat:

Adds a constructed string to the receiver.

- appendString:

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

- applyTransform:reverse:range:updatedRange:

Transliterates the receiver by applying a specified ICU string transform.

- deleteCharactersInRange:

Removes from the receiver the characters in a given range.

- insertString:atIndex:

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

- replaceCharactersInRange:withString:

Replaces the characters from aRange with those in aString.

- replaceOccurrencesOfString:withString:options:range:

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

- setString:

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


String Transformations

These constants specify transforms used by the applyTransform:reverse:range:updatedRange: method.


Inherits From

See Also



A static, plain-text Unicode string object.