---
title: NSMutableString
framework: foundation
role: symbol
role_heading: Class
path: foundation/nsmutablestring
---

# NSMutableString

A dynamic plain-text Unicode string object.

## Declaration

```swift
class NSMutableString
```

## Overview

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

- [init(capacity:)](foundation/nsmutablestring/init(capacity:).md)

### Modifying a String

- [append(_:)](foundation/nsmutablestring/append(_:).md)
- [applyTransform(_:reverse:range:updatedRange:)](foundation/nsmutablestring/applytransform(_:reverse:range:updatedrange:).md)
- [deleteCharacters(in:)](foundation/nsmutablestring/deletecharacters(in:).md)
- [insert(_:at:)](foundation/nsmutablestring/insert(_:at:).md)
- [replaceCharacters(in:with:)](foundation/nsmutablestring/replacecharacters(in:with:).md)
- [replaceOccurrences(of:with:options:range:)](foundation/nsmutablestring/replaceoccurrences(of:with:options:range:).md)
- [setString(_:)](foundation/nsmutablestring/setstring(_:).md)

### Constants

- [String Transformations](foundation/string-transformations.md)

### Instance Methods

- [appendFormat(_:_:)](foundation/nsmutablestring/appendformat(_:_:).md)

## Relationships

### Inherits From

- [NSString](foundation/nsstring.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [ExpressibleByExtendedGraphemeClusterLiteral](swift/expressiblebyextendedgraphemeclusterliteral.md)
- [ExpressibleByStringLiteral](swift/expressiblebystringliteral.md)
- [ExpressibleByUnicodeScalarLiteral](swift/expressiblebyunicodescalarliteral.md)
- [Hashable](swift/hashable.md)
- [NSCoding](foundation/nscoding.md)
- [NSCopying](foundation/nscopying.md)
- [NSItemProviderReading](foundation/nsitemproviderreading.md)
- [NSItemProviderWriting](foundation/nsitemproviderwriting.md)
- [NSMutableCopying](foundation/nsmutablecopying.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
- [NSSecureCoding](foundation/nssecurecoding.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)
