I am using the Xcode beta for developers, and am noticing some subtle differences. Among them is a new attribute for declared properties.
@property(strong)IB
As we know, we cannot release any object in an ARC-based project in iOS 5. So when we want to retain any object for further use at a later stage and don't want ARC to remove the object from memory, then we set the property for the object as "Strong".
It's a replacement for the retain
attribute, as part of Objective-C Automated Reference Counting (ARC). In non-ARC code it's just a synonym for retain
.
A strong reference is a reference to an object that stops it from being deallocated. In other words it creates a owner relationship. Whereas previously you would do this:
**// Non-ARC Compliant Declaration
@property(retain) NSObject *obj;**
Under ARC we do the following to ensure a class instance takes an ownership interest a referenced object (i.e. so it cannot be deallocated until the owner is).
**// ARC Compliant Declaration
@property(strong) NSObject *obj;**