Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import UIKit
- protocol Actionable {
- func action()
- }
- extension UIResponder: Actionable {
- func action() {
- next?.action()
- }
- }
- class ViewModel: UIResponder {
- override func action() {
- print("action")
- }
- }
- class MyView: UIView {
- func tapped() {
- next?.action()
- }
- }
- class ViewController: UIViewController {
- let viewModel = ViewModel()
- let myView = MyView()
- override var next: UIResponder? {
- return viewModel
- }
- override func viewDidLoad() {
- super.viewDidLoad()
- view.addSubview(myView)
- }
- }
- let controller = ViewController(nibName: nil, bundle: nil)
- _ = controller.view
- controller.myView.tapped()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement