Type Method


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


+ (NSCharacterSet *)characterSetWithRange:(NSRange)aRange;



A range of Unicode values.

aRange.location is the value of the first character to return; aRange.location + aRange.length– 1 is the value of the last.

Return Value

A character set containing characters whose Unicode values are given by aRange. If aRange.length is 0, returns an empty character set.


This code excerpt creates a character set object containing the lowercase English alphabetic characters:

NSRange lcEnglishRange;
NSCharacterSet *lcEnglishLetters;
lcEnglishRange.location = (unsigned int)'a';
lcEnglishRange.length = 26;
lcEnglishLetters = [NSCharacterSet characterSetWithRange:lcEnglishRange];

See Also

Creating a Custom Character Set

+ characterSetWithCharactersInString:

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


Specifies lower bound for a Unicode character range reserved for Apple’s corporate use.