Reputation: 289
I know there have been numerous write ups on 'strong' vs. 'weak'. But all docs says that both are 100% synonyms for each other and you can use 'strong' in replace of 'retain', and vice versa.
My question is: if they are same, why did Apple introduce the new 'strong' keyword? I have tested both in a sample project, and both the 'strong' and 'retain' property attributes appear to do the same thing. Don't you think that if Apple introduced the 'strong' attribute, it should disallow the use of 'retain' attribute? Or am I missing something?
Upvotes: 7
Views: 3794
Reputation: 5377
retain
is a leftover from the pre-ARC days where you would increase/decrease an objects retain count
depending on whether you wanted it to hang around in memory.
Obviously with ARC you no longer have to worry about this and I suspect that retain
may simply have been left in for ease of use for the more veteran objective-c programmers out there.
The keywords that are most prevalent with arc are: (strong, weak, nonatomic, readonly, copy)
.
Upvotes: 12