Strong Variables
By default, all object pointer variables are strong variables. That means that assigning an object reference to such a variable causes that object to be automatically retained. Further, the old object reference will be released before the assignment is made. Finally, strong variables are initialized to zero by default. And that’s true whether it’s an instance variable or a local or global variable.
Look at this code, which creates and sets two Fraction objects.
Fraction *f1 = [[Fraction alloc] init];Fraction *f2 = [[Fraction alloc] init];[f1 setTo: 1 over: 2];[f2 setTo: 2 over: 3];
Now when you write the following using manual memory management
f2 = f1;
the effect is to just copy the reference to the Fraction object f1 into ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access