Swift copy by reference

whwn we write a = b, we know that may be a coy by value or reference.


but in the middle of code, it is not always immediate if a and b are strict or instances, hence copied by value or reference.


in addition, that makes it less evident to copy the content.


hence my questions :

– are there good practices to make the difference ? I usually name all my classes with a prefix, but the properties are not prefixed, that would make code less lisible

– or can XCode editor write instances in a specific color ?


is there an easy way to copy the content and not the reference In a new object ?One can use a convenient initializer, but that’s a limited gain over copying each property. is it possible to define an extension for all classes such as : @a = @b to copy content ?

Powered by WPeMatico


You may also like...

Comments are closed.