Is it possible to get the following code to make MyClass2:someFuncWithDefaultImplementation() invoked?
protocol MyProtocol : class {
func someFuncWithDefaultImplementation()
func someFunc()
var someInt:Int { get set }
}
extension MyProtocol {
func someFuncWithDefaultImplementation() {
someInt = 5
}
func someFunc() {
someFuncWithDefaultImplementation()
}
}
class MyClass : MyProtocol {
var someInt = 6
}
class MyClass2 : MyClass
{
func someFuncWithDefaultImplementation()
{
someInt = 7
}
}
...
let class2 = MyClass2()
class2.someFunc()
MyClass2 could have this method added:
func someFunc() {
someFuncWithDefaultImplementation()
}
And it would work, but that is no use if MyProtocol:someFunc() is doing other stuff apart from calling someFuncWithDefaultImplementation() as it would just be code duplication.
Also doing this does not have the desired effect:
extension MyClass2 {
func someFuncWithDefaultImplementation()
{
someInt = 7
}
}