Return to the Alphabetic Index
Return to the Class Browser
Return to the Picture Browser
Copyright (c) 1994 by NeXT Computer, Inc. All Rights Reserved.

NSCharacterSet

Inherits From: NSObject

Conforms To: NSCoding, NSCopying, NSMutableCopying NSObject (NSObject)

Declared In: Foundation/NSCharacterSet.h

Class Description

The NSCharacterSet class declares the programmatic interface to objects that construct immutable descriptions of character sets in the Unicode character encoding. Using NSCharacterSet objects, you can determine if a given Unicode character belongs to a specified set. See NSMutableCharacterSet for a class that constructs descriptions of character sets that can be modified dynamically. NSCharacterSet's primitive methods are characterIsMember: and bitmapRepresentation. Subclasses of NSCharacterSet must implement these two methods.

NSCharacterSet objects can be thought of as loosely analogous to the is1/4 macros (such as isupper())available in the ctype collection of most standard C libraries. NSCharacterSet objects, however, offer much greater flexibility in that you can dynamically construct your own custom character sets against which you can test characters.

The term bitmap in the descriptions below does not refer to bitmap characters in the sense of screen fonts for display. The bitmaps referred to here are compact ordered bit set representations of Unicode character positions or ranges of Unicode characters.

You create standard character setssuch as a set of alphanumerics, or a set of decimal digitsby invoking the NSCharacterSet class object with one of the methods described in Creating a Standard Character Set. These methods provide convenient means to create a standard set without needing to specify the character positons explicitly.

You can also create your own custom character sets by using one of the methods described under Creating a Custom Character Set. To create a character set with multiple disjoint ranges, see the add1/4 methods described in NSMutableCharacterSet.

Creating a Standard Character Set

Creating a Custom Character Set

Getting a Binary Representation

Testing Set Membership

Inverting a Character Set