NumericUITextField

class NumericUITextField : UITextField, UITextFieldDelegate

Class overriding a UITextField in order to enable numeric input only…

  • Tells the delegate when the user changes the text or attributes in the specified text field. Used here to fix the “. ” back to double space

    Declaration

    Swift

    func editingChanged(_ textField: UITextField)

    Parameters

    textField

    The text field containing the changes.

  • Asks the delegate whether to replace the specified text in the text field. Used here to check if entered text conforms a characterset holding decimal values.

    Declaration

    Swift

    func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool

    Parameters

    textField

    The text field containing the changes.

    range

    The current selection range.

    text

    The text to insert

    Return Value

    True if the old text should be replaced by the new text; false if the replacement operation should be aborted.