EnterpriseDS Documentation

Class DSCurrency​Input​Mask

public class DSCurrencyInputMask: DSInputMask  

An input mask, when assigned to a DSTextField, will enforce use of a decimal pad for text entry and only allows digits and a decimal point (no more than one) to be entered.

It's recommended to use prefix text for currency entry which will display in the field.

let textField = DSTextField()

textField.inputMask = DSCurrencyInputMask()
textField.prefixText = Locale.current.currencySymbol ?? "$"

let currencyText = textField.text // <-- $1.23 (as seen)
let currency = textField.rawText // <-- 1.23 (without formatting)
DSCurrencyInputMask DSCurrencyInputMask DSInputMask DSInputMask DSCurrencyInputMask->DSInputMask

Conforms To

DSInputMask

A masking object that controls what can be legally typed into a DSTextField and handles type formatting while that typing takes place. They do not validate but often "partner" up with validation rules.

Initializers

init()

public init()  

Properties

keyboard​Type

public var keyboardType: UIKeyboardType?  

Numbers and the decimal point are needed to enter a currency.

Methods

raw​Text(from:​)

public func rawText(from text: String) -> String  

Raw numeric text and the decimal separator.

should​Allow(replacement​String:​resulting​String:​)

public func shouldAllow(replacementString string: String, resultingString: String) -> Bool  

Only allow numeric digits and one single decimal separator.

apply​Formatting​Mask(to:​)

public func applyFormattingMask(to text: String) -> String