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
}
}