Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
saeedmozaffari committed Apr 28, 2019
1 parent 1b45c35 commit e3f3695
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
5 changes: 3 additions & 2 deletions AKMaskField.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
Base,
);
Expand Down Expand Up @@ -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 = "";
};
Expand Down Expand Up @@ -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 = "";
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
14 changes: 7 additions & 7 deletions AKMaskField/AKMaskField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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 ?? "")
}
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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]) {
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion AKMaskField/AKMaskFieldUtility.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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?] {
Expand Down

0 comments on commit e3f3695

Please sign in to comment.