I'm developing an iPhone app. In a label, I want to show an user's first letter of the name uppercase. How do I do that?
The toUpperCase() method converts the string to uppercase. Here, str. charAt(0). toUpperCase(); gives J.
Just use the capitalizedString method. A string with the first character from each word in the receiver changed to its corresponding uppercase value, and all remaining characters set to their corresponding lowercase values.
If there is only one word String, then use the method
-capitalized
let capitalizedString = myStr.capitalized // capitalizes every word
Otherwise, for multi word strings, you have to extract first character and make only that character upper case.
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