Your copy methods are in my opinion flawed, you create a new instance of the main object but you re-use the relationship object instead of making a new copy of that as well, so called deep copying.
So in Car you should have
func copy() -> Car {
Car(
name: "temporaryNewName",
carData: carData.copy() //<-- New instance
)
}
And in CarData you need to do something similar but loop over the features array and copy each element.
Perhaps unrelated but why do you need both Car and CarData, can't they be merged and personally I prefer to use the @Relationship property wrapper for my relationship properties to make the intention clearer
Topic:
App & System Services
SubTopic:
iCloud
Tags: