Friday, June 14, 2013

NSCharacterSet capitalizedLetterCharacterSet example in Objective C (iOS).


NSCharacterSet capitalizedLetterCharacterSet

Returns a character set containing the characters in the category of Titlecase Letters.

+ (id)capitalizedLetterCharacterSet

Return Value of [NSCharacterSet capitalizedLetterCharacterSet]
A character set containing the characters in the category of Titlecase Letters.

NSCharacterSet capitalizedLetterCharacterSet example.
unichar aChar = [myString characterAtIndex: someIndex];

NSCharacterSet* theCaps [NSCharacterSet capitalizedLetterCharacterSet];
if ([theCaps characterIsMember: aChar])
{
  //Character is an upper case character
}
else
{
  //Character is not an upper case character.
}

Example of [NSCharacterSet capitalizedLetterCharacterSet].

unichar testChar = [inputString characterAtIndex:i+1];
NSCharacterSet *theCaps = [NSCharacterSet capitalizedLetterCharacterSet];
if ([theCaps characterIsMember:testChar]) {
    NSLog(@\"Uppercase\");
}
else {
    NSLog(@\"Lowercase\");
}

NSCharacterSet capitalizedLetterCharacterSet example.
NSCharacterSet *letters = [NSCharacterSet capitalizedLetterCharacterSet];
NSCharacterSet *inStringSet = [NSCharacterSet characterSetWithCharactersInString:@\"ABCD\"];
valid = [letters isSupersetOfSet:inStringSet];

End of NSCharacterSet capitalizedLetterCharacterSet example article.