KawaiKx KawaiKx - 1 year ago 89
Swift Question

length (byte-wise) of a string in swift 2.2

How do we find out the length (byte-wise) of a string

[declared String type, not NSString]
in Swift 2.2?

I know one way out is to use

Is there any other way out?

Answer Source

I think type casting is another easier way to use the methods, properties of NSString class.

print((str as NSString).length)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download