Consider the following example.
struct AStruct{ var i = 0 } class AClass{ var i = 0 var a: A = A(i: 8) func aStruct() -> AStruct{
Try using a class instead of a struct, as it's passed by reference and holds onto the object, while a struct is passed by value (a copy is created).
class
struct