Objective-C ARC: strong vs retain and weak vs assign

strong is the same as retain in a property declaration so for ARC projects use strong instead of retain.

Use assign for C primitive properties and weak for weak references to Objective-C objects.

http://stackoverflow.com/questions/8927727/objective-c-arc-strong-vs-retain-and-weak-vs-assign

and more here: http://developer.apple.com/library/ios/#releasenotes/ObjectiveC/RN-TransitioningToARC/Introduction/Introduction.html

However, note that assign is the default. So, for an int you would use:

@property (nonatomic) int value; // assign by default

http://stackoverflow.com/questions/7827237/what-are-the-default-attributes-for-objective-c-properties/7827261#7827261

Leave a Reply

Your email address will not be published. Required fields are marked *