Skip to content

Latest commit

 

History

History
54 lines (37 loc) · 1.41 KB

AnyFormatKit 0.2.0 MigrationGuide.md

File metadata and controls

54 lines (37 loc) · 1.41 KB

AnyFormatKit 0.2.0 Migration Guide

Breaking Changes

SumTextFormatter

Maximum Decimal Characters

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

Updates

Format input method

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

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)

SumTextFormatter

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
}