I would assume there would be a convenience class somewhere where I could call say
NSArray *alphabet = [SomeClass lowerCaseAlphabet];
instead of having to write it out every time. Is there such a class?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes, a quick search in the docs even throws up some code using
NSMutableCharacterSet:addCharactersInRange:
Adds to the receiver the characters whose Unicode values are in a given range.
Parameters:
aRange:
The range of characters to add.
aRange.location is the value of the first character to add; aRange.location + aRange.length– 1 is the value of the last. If aRange.length is 0, this method has no effect.
Discussion
This code excerpt adds to a character set the lowercase English alphabetic characters:
Availability:
Available in iOS 2.0 and later.
/////////
Personal opinion: If you get stuck for a while on these things it’s often just quicker to create something for yourself. In this case there’s probably not much to lose by making an instance of
NSArraywith objects @”a”, …, @”z”. An array of twenty-six or fifty-two characters is not very big.