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
  • 123,697
  • 21
  • 207
  • 260
shahin ali agharia
  • 1,579
  • 3
  • 19
  • 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
  • 2,743
  • 2
  • 27
  • 48