Let\'s say I have a class called SomeClass
with a string
property name:
@interface SomeClass : NSObject
{
NSString* name;
}
@p
Since name is a (immutable) NSString
, copy or retain makes no difference if you set another NSString
to name. In another word, copy behaves just like retain, increasing the reference count by one. I think that is an automatic optimization for immutable classes, since they are immutable and of no need to be cloned. But when a NSMutalbeString
mstr
is set to name, the content of mstr
will be copied for the sake of correctness.