I was wondering how to capitalize a string found in an object in an NSMutableArray
.
An NSArray
contains the string 'April'
at index 2.
I want this to be changed to 'APRIL'
.
Is there something simple like this?
viewNoteDateMonth.text = [[displayDate objectAtIndex:2] capitalized];
Documentation: http://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html#//apple_ref/occ/instm/NSString/uppercaseString
You can also use lowercaseString and capitalizedString
In case anyone needed the above in swift :
SWIFT 3.0 and above :
this will capitalize your string, make the first letter capital :
this will uppercase your string, make all the string upper case :
Here ya go:
Btw:
"april"
islowercase
➔ [NSString lowercaseString]"APRIL"
isUPPERCASE
➔ [NSString uppercaseString]"April May"
isCapitalized/Word Caps
➔ [NSString capitalizedString]"April may"
isSentence caps
➔ (method missing; see workaround below)Hence what you want is called "uppercase", not "capitalized". ;)
As for "Sentence Caps" one has to keep in mind that usually "Sentence" means "entire string". If you wish for real sentences use the second method, below, otherwise the first: