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];
This question is related to
objective-c
string
cocoa-touch
nsstring
uppercase
In case anyone needed the above in swift :
SWIFT 3.0 and above :
this will capitalize your string, make the first letter capital :
viewNoteDateMonth.text = yourString.capitalized
this will uppercase your string, make all the string upper case :
viewNoteDateMonth.text = yourString.uppercased()
viewNoteDateMonth.text = [[displayDate objectAtIndex:2] uppercaseString];
You can also use lowercaseString and capitalizedString
Source: Stackoverflow.com