Not sure what's going on here, this seems like it should be pretty straight forward. I have a protocol that mutable var, an extension with a mutating function. Things are crapping out in the testClass.testFunc, when I try and use mtkAnimQueAppend declared in the extension, I get this error: "Cannot use mutating member on immutable value: 'self' is immutable.
protocol MTKAnimateValueDelegate {
var mtkAnimQue:[MTKAnimateValue]? {get set}
}
extension MTKAnimateValueDelegate {
///Adds element to que
mutating func mtkAnimQueAppend(element:MTKAnimateValue) {
if mtkAnimQue != nil {
mtkAnimQue?.append(element)
} else {
mtkAnimQue = [element]
}
}
}
class testClass: MTKAnimateValueDelegate {
var mtkAnimQue:[MTKAnimateValue]?
func testFunc() {
var animValue = MTKAnimateValue(fromValue: 10, toValue: 20, inSeconds: 2)
animValue.isAnimating = true
mtkAnimQueAppend(animValue) //ERROR: "Cannot use mutating member on immutable value: 'self' is immutable
}
}