Is it possible to create a variable in a (default implementation of a) protocol? Specifically, I have a variable required by the protocol as:
protocol SearchHandlingDelegate: class {
...
var lastSearchTerm: String { get set }
...
}
and was hoping to have a default implementation of it in a protocol extension as:
extension SearchHandlingDelegate {
...
var lastSearchTerm: String {
set { lastSearchTerm = newValue }
get { return lastSearchTerm }
}
...
}
But this is a bottomless recursive self-call loop… I could have it return the value of another variable, but then it’s not really going to be possible to do this via a default implementation of the protocol…