Created
October 5, 2018 05:17
-
-
Save noppefoxwolf/2a27ffcac0a2b6ceea3ffd1b2f6c3016 to your computer and use it in GitHub Desktop.
Not implementable delegate in protocol extension.
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 | |
import PlaygroundSupport | |
class MyViewController : UIViewController, Interface { | |
lazy var tap = UITapGestureRecognizer(target: self, action: #selector(tapped)) | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
tap.delegate = self | |
view.addGestureRecognizer(tap) | |
} | |
@objc private func tapped(_ sender: UITapGestureRecognizer) { | |
print("hoge") | |
} | |
} | |
protocol Interface: UIGestureRecognizerDelegate { | |
func setup() | |
} | |
extension Interface where Self: MyViewController { | |
func setup() { | |
tap.delegate = self | |
} | |
func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool { | |
return false | |
} | |
} | |
// Present the view controller in the Live View window | |
PlaygroundPage.current.liveView = MyViewController() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment