2
let newLength = countElements(textField.text) + countElements(string) - range.length;

When i'm running my app, it suddenly shows the error of unresolved identifier.

Sulthan
  • 128,090
  • 22
  • 218
  • 270
shahin ali agharia
  • 1,629
  • 4
  • 21
  • 36

1 Answers1

5

It appears you are attempting to use Swift 1.0 code in a later version of Swift. countElements was removed in iOS 8.3 (with Swift 1.2) -- you need to be logged in to see the release notes

in Swift 2.0, it is now str.characters.count

Ultrasaurus
  • 3,031
  • 2
  • 33
  • 52