NSMutableCharacterSet Class Reference
| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/Foundation.framework |
| Availability | Available in OS X v10.0 and later. |
| Companion guide | |
| Declared in | NSCharacterSet.h |
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.
Tasks
Adding and Removing Characters
-
– addCharactersInRange: -
– removeCharactersInRange: -
– addCharactersInString: -
– removeCharactersInString:
Combining Character Sets
Inverting a Character Set
Instance Methods
addCharactersInRange:
Adds to the receiver the characters whose Unicode values are in a given range.
Parameters
- aRange
The range of characters to add.
aRange
.locationis the value of the first character to add; aRange.location +aRange.length– 1is the value of the last. If aRange.lengthis0, this method has no effect.
Discussion
This code excerpt adds to a character set the lowercase English alphabetic characters:
NSMutableCharacterSet *aCharacterSet = [[NSMutableCharacterSet alloc] init]; |
NSRange lcEnglishRange; |
lcEnglishRange.location = (unsigned int)'a'; |
lcEnglishRange.length = 26; |
[aCharacterSet addCharactersInRange:lcEnglishRange]; |
Availability
- Available in OS X v10.0 and later.
Declared In
NSCharacterSet.haddCharactersInString:
Adds to the receiver the characters in a given string.
Parameters
- aString
The characters to add to the receiver.
Discussion
This method has no effect if aString is empty.
Availability
- Available in OS X v10.0 and later.
Declared In
NSCharacterSet.hformIntersectionWithCharacterSet:
Modifies the receiver so it contains only characters that exist in both the receiver and otherSet.
Parameters
- otherSet
The character set with which to perform the intersection.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSCharacterSet.hformUnionWithCharacterSet:
Modifies the receiver so it contains all characters that exist in either the receiver or otherSet.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSCharacterSet.hinvert
Replaces all the characters in the receiver with all the characters it didn’t previously contain.
Discussion
Inverting a mutable character set, whether by invert or by invertedSet, is much less efficient than inverting an immutable character set with invertedSet.
Availability
- Available in OS X v10.0 and later.
See Also
-
– invertedSet(NSCharacterSet)
Declared In
NSCharacterSet.hremoveCharactersInRange:
Removes from the receiver the characters whose Unicode values are in a given range.
Parameters
- aRange
The range of characters to remove.
aRange
.locationis the value of the first character to remove; aRange.location +aRange.length– 1is the value of the last. If aRange.lengthis0, this method has no effect.
Availability
- Available in OS X v10.0 and later.
Declared In
NSCharacterSet.hremoveCharactersInString:
Removes from the receiver the characters in a given string.
Parameters
- aString
The characters to remove from the receiver.
Discussion
This method has no effect if aString is empty.
Availability
- Available in OS X v10.0 and later.
Declared In
NSCharacterSet.h© 2006 Apple Computer, Inc. All Rights Reserved. (Last updated: 2006-05-23)