Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

swift
communitycreator

What is the localizedCapitalized property 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

In Swift, the localizedCapitalized property returns the capitalized representation of a string instance that is produced using the current locale.

Syntax

string.localizedCapitalized

Return Value

This property returns a capitalized representation of a string using the current locale.

Example

// import the foundation framework
import Foundation
// create strings
let str1 = "google"
let str2 = "netflix"
let str3 = "amazon"
let str4 = "apple"
let str5 = "meta"
// get the capitalized representation
print(str1.localizedCapitalized)
print(str2.localizedCapitalized)
print(str3.localizedCapitalized)
print(str4.localizedCapitalized)
print(str5.localizedCapitalized)
Get the localized capitalized representation of a string

Explanation

  • Line 2: We import the Foundation framework. This allows us to use the localizedCapitalized property.
  • Lines 5–9: We create some strings.
  • Lines 12–16: We use localizedCapitalized on the strings and print the output to the console.

RELATED TAGS

swift
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