I have a struct and a class:
class FooClass {
var someValue: String = "123"
}
struct TestStruct {
var aValue: Int = 12
var clsValue: FooClass
}
And I want a deep copy for TestStruct, but the following code will also change clsValue in variable a:
var a = TestStruct(aValue: 10, clsValue: FooClass())
var b = a
b.clsValue.someValue = "abc"
I know the class value in the struct is copied only 'reference', but I want a deep copy for this class when I assigning a to b.
I do know c++ can define a copy constructor or override the = operator. Does Swift support something like that?