Is copy in objective-c a shallow copy or a deep copy, Why?

  ios, question

Is copy in objective-c a shallow copy or a deep copy, Why?

The copy internal implementation of const-like objects (such as NSString, etc.) is actually retain. Such as

– NSString* str1 = @”abcde”;
– NSString* str2 = [str1 copy];

After execution, str1==str2 is actually the same memory, except retaincount plus one. If:

– NSMutableString* str1 = ..
– NSString* str2 = [str1 copy];

Str1! = str2; Copy here is real copy.