New ARC Property Attributes

I read the transition to ARC notes, and I still have confusion about the attributes of the properties we use / can use ... We can use the weak instead of the assignment (with the advantage that the property is nil if the object it is on indicates released) strong instead of saving and what instead of copy? We still use only one copy, or we need to collect a strong copy, for example property (strong,copy) . Maybe I need to practice and read the document again, because ARC is not very clear to me ...

+6
source share
2 answers

The Clang ARC documentation allows you to:

copy implies __strong ownership, as well as the usual behavior of the semantics of the copy on the setter.

Regarding custom customization methods, he should say the following:

The specified property is stored in its metadata, but otherwise the meaning is purely conditional if the property is synthesized.

So, if you implement custom setters, you are responsible for implementing strong or weak semantics in these setters.

+11
source

A copy is implicitly strong because it creates a copy and transfers ownership.

See this documentation:

http://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/ObjectiveC/Chapters/ocProperties.html#//apple_ref/doc/uid/TP30001163-CH17-SW18

+2
source

Source: https://habr.com/ru/post/899829/


All Articles