How to quickly know which attribute to add to a @property
?
I got it for @property (strong)
and @property (weak)
, I think : strong
if the class "owns" the referred-to instance ; weak
if it is just a reference to an object whose existence is not managed to our current class.
If the property is created by dragging-and-dropping from Interface Builder, sometimes there is the cryptic unretain_unsafe
or so. It sounds so complicated to me, but I believe Xcode knows what it does...
I also kind of understand that
retain
,assign
are kind of deprecated...And that it is better (compulsory) to use
copy
forNSString
attributes...But what if I want to have a
@property
to anint
or anenum
?Shall I choose the
weak
attribute if my@property
points to a singleton ?
You see : so many questions for theses attributes !
I thought it would be nice to have a short and clear explanation of these attributes as some members here do :)