Skip to content

Instantly share code, notes, and snippets.

@dbettermann
Created March 6, 2015 23:45
Show Gist options
  • Save dbettermann/88d0e7e5264bb0640056 to your computer and use it in GitHub Desktop.
Save dbettermann/88d0e7e5264bb0640056 to your computer and use it in GitHub Desktop.
Only allow numbers and backspaces in UITextField
func textField(textField: UITextField, shouldChangeCharactersInRange range: NSRange, replacementString string: String) -> Bool {
return string.toInt() != nil || string.isEmpty
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment