Skip to content

Commit c70eb44

Browse files
committed
- Reverting changes made to fix #21
- This fixes #25
1 parent 724cc7c commit c70eb44

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

SVPinView.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Pod::Spec.new do |s|
33

44
s.name = "SVPinView"
5-
s.version = "1.0.6"
5+
s.version = "1.0.7"
66
s.summary = "SVPinView is a customisable library used for accepting alphanumeric pins or one-time passwords."
77

88
s.homepage = "https://github.com/xornorik/SVPinView"

SVPinView/Source/Classes/SVPinView.swift

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,7 @@ public class SVPinView: UIView {
8686
collectionView.register(collectionViewNib, forCellWithReuseIdentifier: reuseIdentifier)
8787
flowLayout.scrollDirection = .vertical //weird!!!
8888
collectionView.isScrollEnabled = false
89-
90-
password = [String](repeating: "", count: pinLength)
91-
89+
9290
self.addSubview(view)
9391
view.frame = bounds
9492
view.autoresizingMask = [UIView.AutoresizingMask.flexibleWidth, UIView.AutoresizingMask.flexibleHeight]
@@ -150,8 +148,12 @@ public class SVPinView: UIView {
150148
// store text
151149
let text = textField.text ?? ""
152150
let passwordIndex = index - 1
153-
// delete if space
154-
password[passwordIndex] = text == " " ? "" : text
151+
if password.count > (passwordIndex) {
152+
// delete if space
153+
password[passwordIndex] = text == " " ? "" : text
154+
} else {
155+
password.append(text)
156+
}
155157
validateAndSendCallback()
156158
}
157159

@@ -215,7 +217,6 @@ public class SVPinView: UIView {
215217
public func getPin() -> String {
216218

217219
guard !isLoading else { return "" }
218-
print("~~~~\(password)")
219220
guard password.count == pinLength && password.joined().trimmingCharacters(in: CharacterSet(charactersIn: " ")).count == pinLength else {
220221
return ""
221222
}

0 commit comments

Comments
 (0)