I plan to use a class object variable to capture user entered data sets in recurring cycles and when a data set is complete add this to an array holding all these class variables. Simple example code in playground:
class Example {
var a = 1
var b = 5
}
var exArray = [Example] () // this is the array holding the class variables
var anExample = Example () // default-init the "re-usable" variable
exArray.append(anExample)
exArray[0].a // results in 1 as expected
exArray[0].b // results in 5 as expected
exArray.count // 1 as expected
// now changing the re-usable variable properties with new user entered data
anExample.a = 3
anExample.b = 7
// appending the altered variable
exArray.append(anExample)
exArray[0].a // shows 3 where I still expect 1
exArray[0].b // shows 7 where I expect 7
exArray.count // shows 2 as expected
it seems the array holds the variable itself (pointer?) not a copy of the variable, so this keeps changing within the array. Any ideas how I can "reset" the class variable without changing the array member?