Blog

Difference between retain & assign

Posted by Sachin Bhardwaj Blogs | iPhone/iPad 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];  

}

post comment
     
COMMENT USING
PREMIUM SPONSORS
Over-C is a holistic consortium of communications and technology specialists. We build, deploy and market both business as well as consumer products and solutions.
Get Career Advice from Experts
SPONSORED BY
  • PDF reports have never been easier to create. With our included WYSIWYG Designer, you can layout your reports, set up your data source and let DynamicPDF ReportWriter do the rest.