I'm stumped about this one: I have a custom class called CClass. Within this class is a counter called counter. I initialize my instances as follows.
var ArrayEntity = [CClass]()
var ParentOne = CClass()
var ParentTwo = CClass()
Later, I assign each Parent to one of the Array entities, like so:
ParentOne = ArrayEntity[i]
ParentTwo = ArrayEntity[i]
Sometimes i will be the same value for both, and thus both will refer to the same Array instance. The trouble is that if I do something like this:
ParentOne.counter = 1
//value of ParentTwo.counter also becomes 1
//ArrayEntity[i].counter also becomes 1
I wish to have these Parent guys be independent of the ArrayEntity entries they are cloned from, but how do I do this?
Thanks much for any insight. Hopefully it's just a stupid oversight!