I have a situation where I want to be able to use an existing field from a class to satisfy an extension to the class that specifies a protocol. Something like this:
class SomeThing {
var foo: String
}
protocol MyProtocol {
var foo: String { get }
func someOtherMethod()
}
extension SomeThing: MyProtocol {
func someOtherMethod() {
}
}
But the compiler is throwing errors in the file that defines the extension, that SomeThing
doesn't fully conform to the protocol. Is there a way to make this work so that the extension just grabs the original object's value?