So far it was:
let string = "my example string"
if count(string) >= 3 { ... }
But now I get an error:
count
is unavailable: access thecount
property on the collection. TypeString
doesn't conform to protocolCollectionType
哦,很简单:
string.characters.count
Again more simplified version
let strLength = string.count
It should be like that
let string = "my example string"
let length = string.characters.count
Because in Swift 2.0 Apple changed global functions to protocol extensions.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.