Blog

Difference between retain & assign

Posted by Sachin Bhardwaj Blogs | iOS Feb 15, 2013
In this blog I will explain basic difference between retain & assign.

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];  

}

COMMENT USING
PREMIUM SPONSORS
MCN is your source for developing solutions involving websites, mobile apps, cloud-computing, databases, BI, back-end services and processes and client-server applications.
SPONSORED BY
  • MCN is your source for developing solutions involving websites, mobile apps, cloud-computing, databases, BI, back-end services and processes and client-server applications.