Reputation: 657
I have an old project I want to revive and I am converting it to ARC and I want to be sure of something, before I hit the save button:
The refactor tool converted all "retained" properties from
@property (nonatomic, retain) UIButton *myButton;
to
@property (nonatomic) UIButton *myButton;
and none of them got the strong
attribute.
I am new to this ARC thing. From the documentation, here: Property Declaration Attributes, I have found out that strong
specifies that there is a strong (owning) relationship to the destination object. That is what I want, but as I have said, the refactor tool have not put anithing in.
Will the code work the same or should I find/replace retains with strongs?
Thanks for your help.
Upvotes: 2
Views: 111
Reputation: 3958
You definitely want to put strong
on the retained properties of your class. The default is assign
, which is probably not what you want.
Upvotes: 2
Reputation: 2857
Depends if you want a strong reference to the object in your property. This is only the way the setter is implemented: (with a retain or not) This means, the object you assign to it won't be released until your ínstance of the class is deallocated. By default the property is assigned. But then again, you do not need to worry much about this with the ARC. I would go safe with the strong.
Upvotes: 0
Reputation: 3011
@property (nonatomic, strong) UIButton *myButton;
strong , weak & unsafe_unretained
are used in ARC for more reference read iOS 5.
If u want to make an project which is ARC enabled and some pages are not supporting to ARC then use this command so that ARC for particular file it will included in ARC. -fno-objc-arc
Upvotes: 1