E
x
c
e
l
P
T
P

What is the difference between retain & assign?

September 12, 2014

Assign creates a reference from one object to another without increasing the source’s retain count.

if (_variable != object)

{   

 [_variable release];  

  _variable = nil;  

  _variable = object;

 }

Retain creates a reference from one object to another and increases the retain count of the source object.

if (_variable != object)

{

  [_variable release];

    _variable = nil;  

_variable = [object retain];  

}