Skip to content

Commit

Permalink
Typo
Browse files Browse the repository at this point in the history
  • Loading branch information
taflanidi committed Apr 10, 2023
1 parent 3406ba6 commit 7d4e3d3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
**⤵️ Added:**

* `NumberInputListener`: a `MaskedTextInputListener` allowing to enter currencies and other numbers
* `"".numberOfOccurencesOf(string)`: a helper method to count occurencies of substrings
* `"".numberOfOccurrencesOf(string)`: a helper method to count occurencies of substrings

**🔄 Modified:**

Expand Down
2 changes: 1 addition & 1 deletion Source/InputMask/InputMask/Classes/Helper/String.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public extension String {
/**
Count the number of occurences of a substring.
*/
func numberOfOccurencesOf(_ string: String) -> Int {
func numberOfOccurrencesOf(_ string: String) -> Int {
return self.components(separatedBy: string).count - 1
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ open class NumberInputListener: MaskedTextInputListener {
}
}

if sanitisedNumberString.numberOfOccurencesOfDecimalSeparator > 0 {
if sanitisedNumberString.numberOfOccurrencesOfDecimalSeparator > 0 {
maskFormat += "{\(sanitisedNumberString.expectedDecimalSeparator)}"
}

Expand Down Expand Up @@ -117,7 +117,7 @@ open class NumberInputListener: MaskedTextInputListener {
let intPart: String
let decPart: String
let expectedDecimalSeparator: String
let numberOfOccurencesOfDecimalSeparator: Int
let numberOfOccurrencesOfDecimalSeparator: Int
}

private func extractNumberAndDecimalSeparator(
Expand All @@ -139,12 +139,12 @@ open class NumberInputListener: MaskedTextInputListener {
return CharacterSet.decimalDigits.isMember(character: c) || String(c) == NumberInputListener.decimalSeparator
}

let numberOfOccurencesOfDecimalSeparator = digitsAndDecimalSeparators.numberOfOccurencesOf(NumberInputListener.decimalSeparator)
if numberOfOccurencesOfDecimalSeparator > 1 {
let numberOfOccurrencesOfDecimalSeparator = digitsAndDecimalSeparators.numberOfOccurrencesOf(NumberInputListener.decimalSeparator)
if numberOfOccurrencesOfDecimalSeparator > 1 {
digitsAndDecimalSeparators =
digitsAndDecimalSeparators
.reversed
.replacing(NumberInputListener.decimalSeparator, with: "", maxReplacements: numberOfOccurencesOfDecimalSeparator - 1)
.replacing(NumberInputListener.decimalSeparator, with: "", maxReplacements: numberOfOccurrencesOfDecimalSeparator - 1)
.reversed
}

Expand All @@ -168,7 +168,7 @@ open class NumberInputListener: MaskedTextInputListener {
intPart: intStr,
decPart: decStr,
expectedDecimalSeparator: expectedDecimalSeparator,
numberOfOccurencesOfDecimalSeparator: numberOfOccurencesOfDecimalSeparator
numberOfOccurrencesOfDecimalSeparator: numberOfOccurrencesOfDecimalSeparator
)
}

Expand Down

0 comments on commit 7d4e3d3

Please sign in to comment.