What exactly is the difference between retain and copy? what is its significance on reference counting?
I know that when an object is allocated using alloc/retain, reference count goes up by one. so how about using copy?
Another question relating to this is, the difference between using
@property(nonatomic, retain) and @property(nonatomic,copy)?
Generally speaking,
copy
creates a new object which has the same value with the original object, and sets the reference count of the new created object to 1 (By the way, reference count of the original object is not affected).However,
copy
is equivalent toretain
for immutable object, which JUST increate the reference count of the original object by 1.