Skip to content

Commit

Permalink
Fix type
Browse files Browse the repository at this point in the history
  • Loading branch information
seaburg committed Oct 26, 2016
1 parent 5498d9f commit 7b79a86
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
8 changes: 4 additions & 4 deletions Example/Example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

/* Begin PBXBuildFile section */
8F0F533B1DC1524A00791173 /* FormattedTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8F0F53371DC1524A00791173 /* FormattedTextField.swift */; };
8F0F533D1DC1524A00791173 /* StringExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8F0F53391DC1524A00791173 /* StringExtensions.swift */; };
8F0F533E1DC1524A00791173 /* UITextFieldExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8F0F533A1DC1524A00791173 /* UITextFieldExtension.swift */; };
8F93C22B1DC15913007A4101 /* StringExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8F93C22A1DC15913007A4101 /* StringExtension.swift */; };
8FD40B571DC1366F0015DB1D /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8FD40B561DC1366F0015DB1D /* AppDelegate.swift */; };
8FD40B591DC1366F0015DB1D /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8FD40B581DC1366F0015DB1D /* ViewController.swift */; };
8FD40B5C1DC1366F0015DB1D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8FD40B5A1DC1366F0015DB1D /* Main.storyboard */; };
Expand All @@ -19,8 +19,8 @@

/* Begin PBXFileReference section */
8F0F53371DC1524A00791173 /* FormattedTextField.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FormattedTextField.swift; sourceTree = "<group>"; };
8F0F53391DC1524A00791173 /* StringExtensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StringExtensions.swift; sourceTree = "<group>"; };
8F0F533A1DC1524A00791173 /* UITextFieldExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UITextFieldExtension.swift; sourceTree = "<group>"; };
8F93C22A1DC15913007A4101 /* StringExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StringExtension.swift; sourceTree = "<group>"; };
8FD40B531DC1366F0015DB1D /* Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Example.app; sourceTree = BUILT_PRODUCTS_DIR; };
8FD40B561DC1366F0015DB1D /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
8FD40B581DC1366F0015DB1D /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
Expand All @@ -44,8 +44,8 @@
8F0F53351DC1524A00791173 /* FormattedTextField */ = {
isa = PBXGroup;
children = (
8F93C22A1DC15913007A4101 /* StringExtension.swift */,
8F0F53371DC1524A00791173 /* FormattedTextField.swift */,
8F0F53391DC1524A00791173 /* StringExtensions.swift */,
8F0F533A1DC1524A00791173 /* UITextFieldExtension.swift */,
);
name = FormattedTextField;
Expand Down Expand Up @@ -155,8 +155,8 @@
buildActionMask = 2147483647;
files = (
8F0F533E1DC1524A00791173 /* UITextFieldExtension.swift in Sources */,
8F0F533D1DC1524A00791173 /* StringExtensions.swift in Sources */,
8F0F533B1DC1524A00791173 /* FormattedTextField.swift in Sources */,
8F93C22B1DC15913007A4101 /* StringExtension.swift in Sources */,
8FD40B591DC1366F0015DB1D /* ViewController.swift in Sources */,
8FD40B571DC1366F0015DB1D /* AppDelegate.swift in Sources */,
);
Expand Down
8 changes: 4 additions & 4 deletions FormattedTextField.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
8FD40B471DBEB3840015DB1D /* UITextFieldExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8FD40B461DBEB3840015DB1D /* UITextFieldExtension.swift */; };
8FFF615C1DBC074E0033E1FC /* FormattedTextField.h in Headers */ = {isa = PBXBuildFile; fileRef = 8FFF615A1DBC074E0033E1FC /* FormattedTextField.h */; settings = {ATTRIBUTES = (Public, ); }; };
8FFF61641DBC07C70033E1FC /* FormattedTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8FFF61621DBC07C70033E1FC /* FormattedTextField.swift */; };
8FFF61651DBC07C70033E1FC /* StringExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8FFF61631DBC07C70033E1FC /* StringExtensions.swift */; };
8FFF61651DBC07C70033E1FC /* StringExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8FFF61631DBC07C70033E1FC /* StringExtension.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand All @@ -19,7 +19,7 @@
8FFF615A1DBC074E0033E1FC /* FormattedTextField.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FormattedTextField.h; sourceTree = "<group>"; };
8FFF615B1DBC074E0033E1FC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
8FFF61621DBC07C70033E1FC /* FormattedTextField.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FormattedTextField.swift; sourceTree = "<group>"; };
8FFF61631DBC07C70033E1FC /* StringExtensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StringExtensions.swift; sourceTree = "<group>"; };
8FFF61631DBC07C70033E1FC /* StringExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StringExtension.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -53,7 +53,7 @@
isa = PBXGroup;
children = (
8FFF61621DBC07C70033E1FC /* FormattedTextField.swift */,
8FFF61631DBC07C70033E1FC /* StringExtensions.swift */,
8FFF61631DBC07C70033E1FC /* StringExtension.swift */,
8FD40B461DBEB3840015DB1D /* UITextFieldExtension.swift */,
8FFF615A1DBC074E0033E1FC /* FormattedTextField.h */,
8FFF615B1DBC074E0033E1FC /* Info.plist */,
Expand Down Expand Up @@ -141,7 +141,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
8FFF61651DBC07C70033E1FC /* StringExtensions.swift in Sources */,
8FFF61651DBC07C70033E1FC /* StringExtension.swift in Sources */,
8FD40B471DBEB3840015DB1D /* UITextFieldExtension.swift in Sources */,
8FFF61641DBC07C70033E1FC /* FormattedTextField.swift in Sources */,
);
Expand Down
22 changes: 11 additions & 11 deletions FormattedTextField/FormattedTextField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ open class FormattedTextField: UITextField {
@IBInspectable open var textMask: String? {
didSet(oldMask) {
var cursorPosition: Int = 0
if let selectedRange = selectedCharachtersRange, let text = text {
if let selectedRange = selectedCharactersRange, let text = text {
cursorPosition = text.distance(from: text.startIndex, to: selectedRange.lowerBound)
} else {
cursorPosition = 0
Expand All @@ -63,7 +63,7 @@ open class FormattedTextField: UITextField {

if selectedTextRange != nil {
let cursorIndex = newFormattedText.index(newFormattedText.startIndex, offsetBy: cursorPosition, limitedBy: newFormattedText.endIndex) ?? newFormattedText.endIndex
selectedCharachtersRange = cursorIndex..<cursorIndex
selectedCharactersRange = cursorIndex..<cursorIndex
}
}
}
Expand Down Expand Up @@ -210,7 +210,7 @@ open class FormattedTextField: UITextField {

cursorPosition = min(cursorPosition, newFormattedText.characters.count)
let cursorIndex = newFormattedText.index(newFormattedText.startIndex, offsetBy: cursorPosition)
selectedCharachtersRange = cursorIndex..<cursorIndex
selectedCharactersRange = cursorIndex..<cursorIndex

sendActions(for: .editingChanged)

Expand Down Expand Up @@ -269,15 +269,15 @@ open class FormattedTextField: UITextField {
return range
}

let maskCharachtersRange = mask.range(fromNsRange: range)!
let maskCharactersRange = mask.range(fromNsRange: range)!
var location = 0
for character in mask[mask.startIndex..<maskCharachtersRange.lowerBound].characters {
for character in mask[mask.startIndex..<maskCharactersRange.lowerBound].characters {
if character == maskSymbol {
location += 1
}
}
var length = 0
for character in mask[maskCharachtersRange].characters {
for character in mask[maskCharactersRange].characters {
if character == maskSymbol {
length += 1
}
Expand All @@ -289,18 +289,18 @@ open class FormattedTextField: UITextField {
guard let mask = self.textMask else {
return range
}
let charachtersRange = mask.range(fromNsRange: range)!
if mask[charachtersRange].contains(String(maskSymbol)) {
let charactersRange = mask.range(fromNsRange: range)!
if mask[charactersRange].contains(String(maskSymbol)) {
return range
}

let searchRange = mask.startIndex..<charachtersRange.lowerBound
let searchRange = mask.startIndex..<charactersRange.lowerBound

let deleteRange: Range<String.Index>
if let removedSymbolRange = mask.range(of: String(maskSymbol), options: .backwards, range: searchRange, locale: nil) {
deleteRange = removedSymbolRange.lowerBound..<charachtersRange.upperBound
deleteRange = removedSymbolRange.lowerBound..<charactersRange.upperBound
} else {
deleteRange = charachtersRange.upperBound..<charachtersRange.upperBound
deleteRange = charactersRange.upperBound..<charactersRange.upperBound
}

return mask.nsrange(fromRange: deleteRange)
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion FormattedTextField/UITextFieldExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import UIKit

extension UITextField {
var selectedCharachtersRange: Range<String.Index>? {
var selectedCharactersRange: Range<String.Index>? {
get {
guard let selectedTextRange = selectedTextRange else {
return nil
Expand Down

0 comments on commit 7b79a86

Please sign in to comment.