Contents

NSMutableCharacterSet

An object representing a mutable set of Unicode character values for use in search operations.

Declaration

class NSMutableCharacterSet

Overview

In Swift, this object bridges to CharacterSet; use NSMutableCharacterSet when you need reference semantics or other Foundation-specific behavior.

The NSMutableCharacterSet class declares the programmatic interface to objects that manage a modifiable set of Unicode characters. You can add or remove characters from a mutable character set as numeric values in NSRange structures or as character values in strings, combine character sets by union or intersection, and invert a character set.

Mutable character sets are less efficient to use than immutable character sets. If you don’t need to change a character set after creating it, create an immutable copy with copy and use that.

NSMutableCharacterSet defines no primitive methods. Subclasses must implement all methods declared by this class in addition to the primitives of NSCharacterSet. They must also implement mutableCopy(with:).

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

Topics

Getting Standard Character Sets

Creating Custom Character Sets

Adding and Removing Characters

Combining Character Sets

Inverting a Character Set