Reference Types vs. Value Types - toant-dev/toandev.github.io GitHub Wiki

Comparations

Reference types share a single copy of their data. Value types keep a unique copy of their data.

Swift represents a reference type as a "class". This is similar to Objective-C, where everything that inherits from NSObject is stored as a reference type.

There are many kinds of value types in Swift, such as "struct, enum, and tuples". You might not realize that Objective-C also uses value types in number literals like NSInteger or even C structures like CGPoint.

Mutability

var and let function differently for reference types and value types. Notice that you defined dog and puppy as constants with let, yet you were able to change the wasFed property. How’s that possible?

For reference types, let means the reference must remain constant. In other words, you can’t change the instance the constant references, but you can mutate the instance itself.

For value types, let means the instance must remain constant. No properties of the instance will ever change, regardless of whether the property is declared with let or var.