1

I get error when I set a limit to the textfield to 300

class ViewController: UIViewController, UITextFieldDelegate {

    func textField(textField: UITextField, shouldChangeCharactersInRange range: NSRange, replacementString string: String) -> Bool {
        let newLength = count(textField.text!.utf16) + count(string.utf16) - range.length
        return newLength <= 300 // Bool
    }

}
Victor Sigler
  • 23,243
  • 14
  • 88
  • 105
marrioa
  • 1,265
  • 4
  • 14
  • 29

0 Answers0