I have a protocol, in which I define a variable.
public protocol CNEnvelopment {
var pan : CGPoint {get set}
var zoom : Float {get set}
var dagObjs : [CNDagObj] {get set} // this one.
I use that protocol type coerce another type, to shield myself from having to test the object type, and write about 30 lines of code for the same behavior in a series of classes:
(theParent as! CNEnvelopment).dagObjs.insert(contentsOf: droppedItems, at: theIndex + 1)
but I get an error when I do that:
Cannot use mutating member on immutable value of type '[CNDagObj]'
do I need to just throw the protocol away and use a class? Because it will work properly if I make CNEnvelopment a class.
is this a limitation of protocols?