objective c - How to choose the attributes of a @property in a nutshell? -


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, assign kind of deprecated...

  • and better (compulsory) use copy nsstring attributes...

  • but if want have @property int or enum ?

  • shall choose weak attribute if @property points 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

  • weak has additional features of being nil-ed out when referred-to object deallocated, never left dangling pointer garbage
  • it not compulsory use copy semantics nsstring property, highly recommended. while nsstring immutable, property might set mutable string subclass, if don't want changing out under you, should use copy
  • the rule of thumb scalar property types pretty simple: not reference counted, neither strong nor weak applies. can readonly or readwrite, depending on need.

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -