Created
May 23, 2020 19:55
-
-
Save MathVasc/4b3983e6cef7815b79f8961e559d1d2d to your computer and use it in GitHub Desktop.
sendFakeActionWithParameter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| public extension UIControl { | |
| func sendFakeAction(for controlEvent: UIControl.Event) { | |
| allTargets.forEach { target in | |
| guard let actions = actions(forTarget: target, forControlEvent: controlEvent), | |
| let responder = target.base as? NSObject else { | |
| return | |
| } | |
| actions.map { Selector($0) }.forEach { selector in | |
| if responder.responds(to: selector) { | |
| responder.perform(selector, with: self) | |
| } | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment