Swift Value and Reference Types Explained

Sometimes an assignment results in a new copy of instance data and sometimes the end state is a shared instance. How’s a guy to know which is which?

Apple has an thorough introduction to working with both reference and value types.

And once that is clear, the next obvious question is, where do I use one type over the other? Apple sums this up nicely:

One of the primary reasons to choose value types over reference types is the ability to more easily reason about your code. If you always get a unique, copied instance, you can trust that no other part of your app is changing the data under the covers. This is especially helpful in multi-threaded environments where a different thread could alter your data out from under you. This can create nasty bugs that are extremely hard to debug.