I am wondering if such a goal can be achieved.
I have a playground like this:
protocol Foo { func testPrint() } extension Foo { func testPrint() { print("Protocol extension call") } } struct Bar: Foo { func testPrint() { // Calling self or super go call default implementation self.testPrint() print("Call from struct") } } let sth = Bar() sth.testPrint()
I can provide a default implementation in extension , but what if Bar needs everything there is in the default implementation plus additional things?
It is somehow like calling super. methods super. in class es to fulfill the requirement of implementing each property, etc., but I don’t see the possibility of achieving the same with structs .
oop swift swift2 protocols
cojoj Sep 16 '15 at 7:51 2015-09-16 07:51
source share