To convert a string to lowercase in Swift, you can use the lowercased()
method.
In this example,
str
with the value "Hello World"
.lowercased()
on str
and store the result in a new variable lowercaseStr
.lowercaseStr
.let str = "Hello World"
let lowercaseStr = str.lowercased()
print(lowercaseStr)
hello world
In this example,
str
with the value "Swift Programming"
.lowercased()
on str
and store the result in a new variable lowercaseStr
.lowercaseStr
.let str = "Swift Programming"
let lowercaseStr = str.lowercased()
print(lowercaseStr)
swift programming
In this tutorial, we learned How to convert String to Lowercase in Swift language with well detailed examples.