Skip to content
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
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0820"
version = "1.3">
version = "1.8">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
Expand Down Expand Up @@ -56,7 +56,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
17 changes: 17 additions & 0 deletions Pod/Extensions/StringExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,21 @@ internal extension String {
var hasOnlyNewlineSymbols: Bool {
return trimmingCharacters(in: CharacterSet.newlines).isEmpty
}

var length: Int {
#if swift(>=3.2)
return count
#else
return characters.count
#endif
}

@available(swift 3.0)
@discardableResult mutating func removeLastCharacter() -> String {
#if swift(>=3.2)
return String(removeLast())
#else
return String(characters.removeLast())
#endif
}
}
8 changes: 4 additions & 4 deletions Pod/PinCodeTextField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ import UIKit
}

private func isPlaceholder(_ i: Int) -> Bool {
let inputTextCount = text?.count ?? 0
let inputTextCount = text?.length ?? 0
return i >= inputTextCount
}

Expand Down Expand Up @@ -297,7 +297,7 @@ import UIKit
let newText = text.map { $0 + character } ?? character
let isNewline = character.hasOnlyNewlineSymbols
let isCharacterMatchingCharacterSet = character.trimmingCharacters(in: allowedCharacterSet).isEmpty
let isLengthWithinLimit = newText.count <= characterLimit
let isLengthWithinLimit = newText.length <= characterLimit
return !isNewline && isCharacterMatchingCharacterSet && isLengthWithinLimit
}
}
Expand All @@ -324,7 +324,7 @@ extension PinCodeTextField: UIKeyInput {
let newText = text.map { $0 + charToInsert } ?? charToInsert
text = newText
delegate?.textFieldValueChanged(self)
if (newText.count == characterLimit) {
if (newText.length == characterLimit) {
if (delegate?.textFieldShouldEndEditing(self) ?? true) {
let _ = resignFirstResponder()
}
Expand All @@ -334,7 +334,7 @@ extension PinCodeTextField: UIKeyInput {

public func deleteBackward() {
guard hasText else { return }
text?.removeLast()
text?.removeLastCharacter()
delegate?.textFieldValueChanged(self)
}
}
Expand Down
4 changes: 2 additions & 2 deletions Pod/TextHelper/TextHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ class TextHelper {
}

func character(atIndex i: Int) -> Character? {
let inputTextCount = text?.count ?? 0
let placeholderTextLength = placeholderText?.count ?? 0
let inputTextCount = text?.length ?? 0
let placeholderTextLength = placeholderText?.length ?? 0
let character: Character?
if i < inputTextCount {
let string = text ?? ""
Expand Down