Get the Length of String in Swift

September 27, 2017

You can get the length of the string following way

var str: String = "string 1 "
print ("Length of the string : \(str.characters.count)")

Output
Length of the string : 9