objective c - How to choose the attributes of a @property in a nutshell? -
this question has answer here:
how know attribute add @property ?
i got @property (strong) , @property (weak), think : strong if class "owns" referred-to instance ; weak if reference object existence not managed our current class.
if property created dragging-and-dropping interface builder, there cryptic unretain_unsafe or so. sounds complicated me, believe xcode knows does...
i kind of understand
retain,assignkind of deprecated...and better (compulsory) use
copynsstringattributes...but if want have
@propertyintorenum?shall choose
weakattribute if@propertypoints singleton ?
you see : so many questions theses attributes !
i thought nice have short , clear explanation of these attributes members here :)
a few notes in no particular order
weakhas additional features of being nil-ed out when referred-to object deallocated, never left dangling pointer garbage- it not compulsory use
copysemanticsnsstringproperty, highly recommended. whilensstringimmutable, property might set mutable string subclass, if don't want changing out under you, should usecopy - the rule of thumb scalar property types pretty simple: not reference counted, neither
strongnorweakapplies. canreadonlyorreadwrite, depending on need.
Comments
Post a Comment