Skip to content

Commit

Permalink
Update for Swift 2.2 / Xcode 7.3
Browse files Browse the repository at this point in the history
  • Loading branch information
kyleweiner committed Mar 22, 2016
1 parent 2bbaef4 commit af51165
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion KWStepper.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "KWStepper"
s.version = "2.1.2"
s.version = "2.1.3"
s.summary = "A stepper control with flexible UI and tailored UX."
s.homepage = "https://github.com/kyleweiner/KWStepper"
s.license = { :type => "MIT", :file => "LICENSE" }
Expand Down
15 changes: 9 additions & 6 deletions Source/KWStepper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,16 @@ public class KWStepper: UIControl {
public init(decrementButton: UIButton, incrementButton: UIButton) {
self.decrementButton = decrementButton
self.incrementButton = incrementButton

super.init(frame: CGRectZero)

self.decrementButton.addTarget(self, action: "decrementValue", forControlEvents: .TouchUpInside)
self.incrementButton.addTarget(self, action: "incrementValue", forControlEvents: .TouchUpInside)
self.decrementButton.addTarget(self, action: #selector(decrementValue), forControlEvents: .TouchUpInside)
self.incrementButton.addTarget(self, action: #selector(incrementValue), forControlEvents: .TouchUpInside)

self.decrementButton.addGestureRecognizer(UILongPressGestureRecognizer(target: self, action: "didLongPress:"))
self.incrementButton.addGestureRecognizer(UILongPressGestureRecognizer(target: self, action: "didLongPress:"))
for button in [self.decrementButton, self.incrementButton] {
let longPressRecognizer = UILongPressGestureRecognizer(target: self, action: #selector(didLongPress(_:)))
button.addGestureRecognizer(longPressRecognizer)
}
}

/// `KWStepper` does not support `NSCoding`.
Expand Down Expand Up @@ -214,12 +217,12 @@ public class KWStepper: UIControl {
longPressTimer = NSTimer.scheduledTimerWithTimeInterval(
autoRepeatInterval,
target: self,
selector: sender.view == incrementButton ? "incrementValue" : "decrementValue",
selector: sender.view == incrementButton ? #selector(incrementValue) : #selector(decrementValue),
userInfo: nil,
repeats: true
)
}

private func endLongPress() {
guard let timer = longPressTimer else { return }

Expand Down

0 comments on commit af51165

Please sign in to comment.