Class

NSMutableCharacterSet

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

Declaration

@interface NSMutableCharacterSet : NSCharacterSet

Overview

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 mutableCopyWithZone:.

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

Topics

Getting Standard Character Sets

+ alphanumericCharacterSet

Returns a character set containing the characters in Unicode General Categories L*, M*, and N*.

+ capitalizedLetterCharacterSet

Returns a character set containing the characters in Unicode General Category Lt.

+ controlCharacterSet

Returns a character set containing the characters in Unicode General Category Cc and Cf.

+ decimalDigitCharacterSet

Returns a character set containing the characters in the category of decimal numbers.

+ decomposableCharacterSet

Returns a character set containing individual Unicode characters that can also be represented as composed character sequences (such as for letters with accents), by the definition of “standard decomposition” in version 3.2 of the Unicode character encoding standard.

+ illegalCharacterSet

Returns a character set containing values in the category of Non-Characters or that have not yet been defined in version 3.2 of the Unicode standard.

+ letterCharacterSet

Returns a character set containing the characters in Unicode General Category L* & M*.

+ lowercaseLetterCharacterSet

Returns a character set containing the characters in Unicode General Category Ll.

+ newlineCharacterSet

Returns a character set containing the newline characters (U+000A ~ U+000D, U+0085, U+2028, and U+2029).

+ nonBaseCharacterSet

Returns a character set containing the characters in Unicode General Category M*.

+ punctuationCharacterSet

Returns a character set containing the characters in Unicode General Category P*.

+ symbolCharacterSet

Returns a character set containing the characters in Unicode General Category S*.

+ uppercaseLetterCharacterSet

Returns a character set containing the characters in Unicode General Category Lu and Lt.

+ whitespaceAndNewlineCharacterSet

Returns a character set containing characters in Unicode General Category Z*, U+000A ~ U+000D, and U+0085.

+ whitespaceCharacterSet

Returns a character set containing the characters in Unicode General Category Zs and CHARACTER TABULATION (U+0009).

Creating Custom Character Sets

+ characterSetWithCharactersInString:

Returns a character set containing the characters in a given string.

+ characterSetWithRange:

Returns a character set containing characters with Unicode values in a given range.

+ characterSetWithBitmapRepresentation:

Returns a character set containing characters determined by a given bitmap representation.

+ characterSetWithContentsOfFile:

Returns a character set read from the bitmap representation stored in the file a given path.

Adding and Removing Characters

- addCharactersInRange:

Adds to the receiver the characters whose Unicode values are in a given range.

- removeCharactersInRange:

Removes from the receiver the characters whose Unicode values are in a given range.

- addCharactersInString:

Adds to the receiver the characters in a given string.

- removeCharactersInString:

Removes from the receiver the characters in a given string.

Combining Character Sets

- formIntersectionWithCharacterSet:

Modifies the receiver so it contains only characters that exist in both the receiver and another set.

- formUnionWithCharacterSet:

Modifies the receiver so it contains all characters that exist in either the receiver or another set.

Inverting a Character Set

- invert

Replaces all the characters in the receiver with all the characters it didn’t previously contain.

Relationships

Inherits From

See Also

Characters

NSCharacterSet

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

unichar

Type for UTF-16 code units.