I'm trying to create a protocol that would be implemented by certain classes, all of them should also implement UIScrollViewDelegate
. What I thought of is for my new protocol to implement the protocol UIScrollViewDelegate
.
protocol MyProtocol: UIScrollViewDelegate {
var myVar: NSString { get }
func myMethod()
}
As the protocol should have its default implementation I also created an extension for this protocol.
extension MyProtocol {
func myMethod() {
print("I'm printing")
}
func scrollViewDidScroll(scrollView: UIScrollView) {
print("I'm scrollin")
}
}
It compiles, but does not work. What am I doing wrong and what would be the right way to create a default implementation of expanded protocol?