I'm working with cocoa on the iPhone and I'm looking for some method like:
NSString *s = @"Hello";
[s isStringStartsWithUpperCaseCharacter]
-(BOOL) isStringStartsWithUpperCaseCharacter;
The first letter of the string may be non ASCII letter like: Á
, Ç
, Ê
...
Is there some method which can helps me?
I saw in the documentation that there are some methods to convert the string to uppercase and to lowercase but there are no methods for ask if the string is lowercase
or uppercase
.
BOOL isUppercase = [[NSCharacterSet uppercaseLetterCharacterSet] characterIsMember:[s characterAtIndex:0]];
Edit:
I'm not sure what's the difference between uppercaseLetterCharacterSet
and capitalizedLetterCharacterSet
. If someone finds out, please leave a comment!
2nd Edit:
Thanks, Ole Begemann, for finding out about the differences. I edited the code to make it work as expected.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With