David DelMonte David DelMonte - 1 year ago 156
Swift Question

How do I get the length of a String in Swift3 on macOS

How do I get the length of a

in 'Swift3' on macOS?

This used to work in Swift2:

if purchaseDateString.length == 0 {
purchaseDateString = "n/a"

What is Swift3 equivalent for finding String's length.


There are answers to this question as Martin points out. The referred question has 30 answers. However, as far as I can tell, none of them relate specifically to Swift3. I could be wrong..

Answer Source

Have you try characters.count

if purchaseDateString.characters.count == 0 {
     purchaseDateString = "n/a"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download