From e3f3695be09a75c65317dc38fd2d02d17bbecca2 Mon Sep 17 00:00:00 2001 From: SaeedMozaffari Date: Sun, 28 Apr 2019 09:41:48 +0430 Subject: [PATCH] Initial Commit --- AKMaskField.xcodeproj/project.pbxproj | 5 +++-- .../xcshareddata/IDEWorkspaceChecks.plist | 8 ++++++++ AKMaskField/AKMaskField.swift | 14 +++++++------- AKMaskField/AKMaskFieldUtility.swift | 2 +- 4 files changed, 19 insertions(+), 10 deletions(-) create mode 100644 AKMaskField.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/AKMaskField.xcodeproj/project.pbxproj b/AKMaskField.xcodeproj/project.pbxproj index e716453..c8e9b69 100644 --- a/AKMaskField.xcodeproj/project.pbxproj +++ b/AKMaskField.xcodeproj/project.pbxproj @@ -226,6 +226,7 @@ developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( + English, en, Base, ); @@ -342,7 +343,7 @@ SKIP_INSTALL = YES; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 5.0; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; @@ -374,7 +375,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 5.0; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; diff --git a/AKMaskField.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/AKMaskField.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/AKMaskField.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + 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?] {