WHAT IS THE DIFFERENCE BETWEEN RETAIN & ASSIGN?

Tarun Kumar

Total Post:107

Points:535
Posted by  Tarun Kumar
 599  View(s)
Ratings:
Rate this:
  1. Tarun Kumar

    Post:107

    Points:535
    What is the difference between retain & assign?

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

    if (obj1 !=
    ob2)
    
    { 
       [obj1 release];
       obj1 = nil;
       obj1 = obj2; }

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

    if (obj1 !=
    obj2)
    
    {
       [obj1 release];
       obj1 = nil;
       obj1 = [obj2 retain]; }

      Modified On Mar-28-2018 04:53:54 AM

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!