Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating some lines to fit with swift 5 #54

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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