Skip to content

Commit 4cdea6c

Browse files
committed
Adding Doc comments
1 parent a82f9b9 commit 4cdea6c

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

Sources/DeclarativeLayoutKit/Chaining/Actions/UIGestureRecognizer+Action.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88
import UIKit
99

1010

11-
/// Add action to a UIGestureRecognizer.
11+
/// **⚠️ Don't forget about ARC when use self or some parent view in action closure, to prevent retain cycle**
1212
///
1313
/// Using:
1414
///
1515
/// UIView()
16-
/// .addGesture(gesture: UITapGestureRecognizer()
17-
/// .addAction {
18-
/// // ...
19-
/// })
16+
/// .addGesture(UITapGestureRecognizer()
17+
/// .addAction {
18+
/// // ...
19+
/// })
2020
extension UIGestureRecognizer {
2121
func addAction(_ action: @escaping () -> Void) -> Self {
2222
let action = ClosureAction(attachTo: self, closure: action)

Sources/DeclarativeLayoutKit/Chaining/Actions/UIView+Gesture.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,15 @@ public extension UIView {
3535
return self
3636
}
3737

38-
func addGesture<Gesture: UIGestureRecognizer>(overwrite: Bool = false, gesture: Gesture) -> Self {
38+
/// - Parameters:
39+
/// - overwrite: if true - remove previous targets for current event.
40+
@discardableResult
41+
func addGesture<Gesture: UIGestureRecognizer>(overwrite: Bool = false, _ gesture: Gesture) -> Self {
42+
isUserInteractionEnabled = true
43+
if overwrite {
44+
gestureRecognizers?.removeAll(where: { (gesture: UIGestureRecognizer) in gesture is Gesture })
45+
}
46+
3947
addGestureRecognizer(gesture)
4048
return self
4149
}

0 commit comments

Comments
 (0)