To support iOS 4.3 with ARC, I think the proper way is to use assign
:
@property (assign, nonatomic) UIView *view;
@property (assign, nonatomic) MYNode *node;
Is that correct? I also see the following in Apple's doc for Transitioning to ARC:
For declared properties, you should use assign instead of weak; for variables you should use __unsafe_unretained instead of __weak.
However, if I use the current Xcode (4.4.1), changing a Single View app target to 4.3, and Ctrl-drag a UIButton to the .h
file to create an outlet, the generated code is:
@property (unsafe_unretained, nonatomic) IBOutlet UIButton *foo;
Why the difference and which one should be used?
According to 4.1.1. Property declarations in the llvm documentation "assign" and "unsafe_unretained" are equivalent in a property declaration:
ADDED: In the clang source code http://clang.llvm.org/doxygen/SemaObjCProperty_8cpp_source.html you find
00523 // 'unsafe_unretained' is alias for 'assign'.
00524 if (Attributes & ObjCDeclSpec::DQ_PR_unsafe_unretained)
00525 PDecl->setPropertyAttributes(ObjCPropertyDecl::OBJC_PR_assign);