A shallow copy is like a reference type, while a deep copy is a value type, for example.
A shallow copy is a source object that is shared with a copy object, and only refers to a variable (with a different name). Changes to any of these objects affect the other object. For example, a person at the beginning of the call Zhang San, later renamed John Doe, but still the same person, whether it is Zhang three missing arms or legs or Li four short legs, is this person unlucky.
Deep copy means that the source and copy objects are independent of each other, and any changes to the object do not affect the other object. For example, a person named Zhang San, later with his cloning (assuming the law allows) another person, called John Doe, whether it is Zhang three short arms or legs or Li four lack of arms and legs will not affect another person. A typical value object, such as a predefined type int32,double, and a struct (struct), enumeration (enum), and so on.
NSString copy and retain is a typical deep copy and shallow copy of the distinction, retain just increase the reference count, any reference to the source data may cause the source data changes, and copy is to create a new copy object, the source data will not be modified.
Copy retain for deep and shallow copies and NSString