Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

swift
uppercase
string
communitycreator

What is the localizedUppercase property of a String in Swift?

Theodore Kelechukwu Onyejiaku

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

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 framework
import Foundation
// create strings
let str1 = "Metamask"
let str2 = "Solana"
let str3 = "NFT"
let str4 = "BlockCHAIN"
let str5 = "Meta"
// get the capitalized representation
print(str1.localizedUppercase)
print(str2.localizedUppercase)
print(str3.localizedUppercase)
print(str4.localizedUppercase)
print(str5.localizedUppercase)
Getting the uppercase of a String in Swift

Explanation

  • Line 2: We import the Foundation framework, which provides methods and functionalities such as the localizedUppercase property.
  • Lines 5 to 9: We create some strings.
  • Lines 12 to 16: We get the uppercase representations of the strings we created using the localizedUppercase property and print the returned values to the console.

RELATED TAGS

swift
uppercase
string
communitycreator

CONTRIBUTOR

Theodore Kelechukwu Onyejiaku

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring