let newLength = countElements(textField.text) + countElements(string) - range.length;
When i'm running my app, it suddenly shows the error of unresolved identifier.
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