Variable, that allowed to input limited number of characters after decimal separator now get-only.
// open var maximumDecimalCharacters: Int = 2
open var maximumDecimalCharacters: Int {
return numberFormatter.maximumFractionDigits
}
Now maximumFractionDigits parse from format (number of '#' after decimal separator).
SumTextInputFormatter(textPattern: "#.###,#### $") // 4 '#' after ',' - maximumFractionDigits
func formatInput() - method, that format text and return it as result with new caret offset. Now TextInputFormatter use this method in shouldChangeTextIn() by default.
func formatInput(currentText: String, range: NSRange, replacementString text: String) -> FormattedTextValue
FormattedTextValue is a tuple, that use for return formatted text and caret offset from begin from input formatter.
public typealias FormattedTextValue = (formattedText: String, caretBeginOffset: Int)
Now sum text formatter use NumberFormatter under the hood.
private let numberFormatter: NumberFormatter
Was added init method with number formatter. Old init method still works.
public init(numberFormatter: NumberFormatter) {
self.numberFormatter = numberFormatter
}