With ARC why use @properties anymore?

前端 未结 5 1502
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-29 10:25

In non-ARC code retained properties handily take care of memory management for you using the self.property = syntax, so we were taught to use them for practical

5条回答
  •  情歌与酒
    2020-12-29 10:58

    Apart from retained there are also other modifiers that on occasions may become quite useful, e.g. 'copy' when assigning blocks to class member variables, or 'readonly' which ensures the property can't be written to. Also don't forget about 'dynamic' properties when working with Core Data, and the possibility to execute custom code when assigning or retrieving a property (when defining custom getters/setters instead of using @synthesize).

提交回复
热议问题