In the previous version of Swift, I had the following code.
func myfunc(mystr: String) {
if mystr.utf16Count >= 3 {
With the latest release of Swift 1.2, I now get the following error.
'utf16Count' is unavailable: Take the count of a UTF-16 view instead, i.e. count(str.utf16)
So I change my code as follows:
func myfunc(mystr: String) {
if count(mystr.utf16) >= 3 {
But that doesn't work. I now get the following error message instead.
'(String.UTF16View) -> _' is not identical to 'Int16'
What is the correct way to get the length of a string with Swift 1.2?
str.count
– Roadside