OC Syntax -- ask the specific difference between copy and retain in NSString attribute declaration, nsstringretain
Ask the specific difference between copy and retain in NSString attribute declaration. copy is to release the source object, and then copy the new object to the source object.
Retain is to release the source object and then the new object retain is then paid to the source object
The fundamental difference is that when the object performs deep copy, the copy operation should open up a new storage space, and the shortest time of the shortest copy is the same. In terms of reference count, retain adds 1 to the reference count of the source object.
The reference count of the source object is increased by 1 in the case of shallow replication, the reference count of the source object remains unchanged in the case of deep replication, and the reference count of the new object is increased by 1.
NSString * str = @ "hello ";
// Copy the original copy mode
NSMutableString * strM = [str copy];
// [StrM appendString: @ "123"]; it cannot run because copy is copied as is and the memory address is the same. I can't think that another type points to him. He is the same thing.
Deep replication: to change
Light replication: UNCHANGED