diff --git a/AKMaskField/AKMaskField.swift b/AKMaskField/AKMaskField.swift index bb62819..119c436 100644 --- a/AKMaskField/AKMaskField.swift +++ b/AKMaskField/AKMaskField.swift @@ -158,10 +158,10 @@ open class AKMaskField: UITextField, UITextFieldDelegate { var copy: Bool = true var _maskTemplate = String(maskTemplateDefault) - if maskTemplate.characters.count == maskExpression!.characters.count - (maskBlocks.count * 2) { + if maskTemplate.count == maskExpression!.count - (maskBlocks.count * 2) { copy = false _maskTemplate = maskTemplate - } else if maskTemplate.characters.count == 1 { + } else if maskTemplate.count == 1 { _maskTemplate = maskTemplate } @@ -217,7 +217,7 @@ open class AKMaskField: UITextField, UITextFieldDelegate { return } - _ = textField(self, shouldChangeCharactersIn: NSMakeRange(0, maskText.characters.count), replacementString: text ?? "") + _ = textField(self, shouldChangeCharactersIn: NSMakeRange(0, maskText.count), replacementString: text ?? "") } } @@ -457,8 +457,8 @@ open class AKMaskField: UITextField, UITextFieldDelegate { var location = range.location var savedLocation = range.location - for replacementCharacter in string.characters { - if location == maskText?.characters.count { break } + for replacementCharacter in string { + if location == maskText?.count { break } // Find next character // If character outside the block, jump to first character of the next block @@ -545,7 +545,7 @@ open class AKMaskField: UITextField, UITextFieldDelegate { // Start carret position var _location = _range.location - for replacementCharacter in _string.characters { + for replacementCharacter in _string { if _location > maskBlocks[i].templateRange.length { break } if matchTextCharacter(replacementCharacter, withMaskCharacter: maskBlocks[i].chars[_location]) { @@ -566,7 +566,7 @@ open class AKMaskField: UITextField, UITextFieldDelegate { if !_string.isEmpty { - var maskTextRange = NSMakeRange(_range.location, _string.characters.count) + var maskTextRange = NSMakeRange(_range.location, _string.count) // Object diff --git a/AKMaskField/AKMaskFieldUtility.swift b/AKMaskField/AKMaskFieldUtility.swift index 0970b25..7af8087 100644 --- a/AKMaskField/AKMaskFieldUtility.swift +++ b/AKMaskField/AKMaskFieldUtility.swift @@ -61,7 +61,7 @@ public class AKMaskFieldUtility { public class func matchesInString(_ string: String, pattern: String) -> [NSTextCheckingResult] { return try! NSRegularExpression(pattern: pattern, options: .caseInsensitive) - .matches(in: string, options: NSRegularExpression.MatchingOptions(rawValue: 0), range: NSMakeRange(0, string.characters.count)) + .matches(in: string, options: NSRegularExpression.MatchingOptions(rawValue: 0), range: NSMakeRange(0, string.count)) } public class func findIntersection(_ ranges: [NSRange], withRange range: NSRange) -> [NSRange?] {