Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between retain and copy?

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)?

like image 631
binbash Avatar asked Dec 07 '22 23:12

binbash


1 Answers

retain -- is done on the created object, it just increase the reference count.

copy -- create a new object

like image 89
Girish Kolari Avatar answered Jan 01 '23 18:01

Girish Kolari