What is the localizedUppercase property of a String in Swift?
Overview
The localizedUppercase property of a String instance in Swift is used to get the uppercase version of a string that is produced using the current locale.
Syntax
string.localizedUppercase
Return value
This property returns the uppercase representation of the String instance string.
Example
Let’s look at the code below:
// import the foundation frameworkimport Foundation// create stringslet str1 = "Metamask"let str2 = "Solana"let str3 = "NFT"let str4 = "BlockCHAIN"let str5 = "Meta"// get the capitalized representationprint(str1.localizedUppercase)print(str2.localizedUppercase)print(str3.localizedUppercase)print(str4.localizedUppercase)print(str5.localizedUppercase)
Explanation
- Line 2: We import the
Foundationframework, which provides methods and functionalities such as thelocalizedUppercaseproperty. - Lines 5 to 9: We create some strings.
- Lines 12 to 16: We get the uppercase representations of the strings we created using the
localizedUppercaseproperty and print the returned values to the console.