I have this code:
NSCharacterSet *characterSet = [NSCharacterSet characterSetWithCharactersInString:@"abcdefghijklmnopqrstuvwxyz1234567890"];
NSLog(@"character set: %i", [characterSet characterIsMember:(unichar)"a"]);
The NSLog returns 0, when I expect it to return 1. How am i doing this wrong?
You have cast a C string (a pointer to char
) to unichar
.
Replacing "a"
by 'a'
produces the expected result:
NSLog(@"character set: %i", [characterSet characterIsMember:(unichar)'a']);