Swift String lowercased()

In this tutorial, we will learn about the Swift String uppercased() method with the help of examples.

The lowercased() method converts all uppercase characters in a string into lowercase characters.


var message = "SWIFT IS FUN"

// convert message to lowercased print(message.lowercased())
// Output: swift is fun

lowercased() Syntax

The syntax of lowercased() method is:


Here, string is an object of the String class.

lowercased() Parameters

lowercased() method doesn't take any parameters.

lowercased() Return Value

returns the given string in lowercase

Example 1: Swift lowercased()

var string = "this should be lowercase!"
// string with numbers // all alphabets should be lowercase var string2 = "tH!S SH0uLd B3 UpP3rCas3!"


this should be lowercase!
th!s sh0uld b3 upp3rcas3!

Example 2: Compare Two Strings Using lowercased()

// first string
var str1 = "swift is awesome!"

// second string
var str2 = "SwIfT Is AwEsOmE!"

// compare two strings if(str1.lowercased() == str2.lowercased()) {
print("The strings are same.") } else { print("The strings are not same.") }


The strings are same.
Did you find this article helpful?