SFRVFTU CZXFBL \<XFBLVSM-BCFM XFBLRVFSZ*UFNT-BCFM>SFTQPOTFJO MFUQBSTFE3FTQPOTF3FTQPOTF SFTQPOTFSFTQPOTF %JTQBUDI2VFVFNBJOBTZOD\ VSM-BCFM UFYUQBSTFE3FTQPOTF VSM RVFSZ*UFNT-BCFM UFYUQBSTFE3FTQPOTF BSHT ^ ^ ^ ^ ※ͨͩ͠ɺunownedͰ͖ͳ͍ `property` may only be applied to class and class-bound protocol types, not ‘Type'
internal differences? https://stackoverflow.com/a/42847825 > In my usage, the common case arises in situations where a closure needs a capture list involving self in order to avoid a retain cycle. In such a situation, it is almost always possible to say [unowned self] in the capture list. When we do: > * It is more convenient for the programmer because there is nothing to unwrap. [weak self] would be an Optional in need of unwrapping in order to use it. > * It is more efficient, partly for the same reason (unwrapping always adds an extra level of indirection) and partly because it is one fewer weak reference for the runtime's scratchpad list to keep track of.
internal differences? https://stackoverflow.com/a/42847825 > In my usage, the common case arises in situations where a closure needs a capture list involving self in order to avoid a retain cycle. In such a situation, it is almost always possible to say [unowned self] in the capture list. When we do: > * It is more convenient for the programmer because there is nothing to unwrap. [weak self] would be an Optional in need of unwrapping in order to use it. > * It is more efficient, partly for the same reason (unwrapping always adds an extra level of indirection) and partly because it is one fewer weak reference for the runtime's scratchpad list to keep track of.
> Unlike a weak reference, however, an unowned reference is used when the other instance has the same lifetime or a longer lifetime. You indicate an unowned reference by placing the unowned keyword before a property or variable declaration. > An unowned reference is expected to always have a value. As a result, ARC never sets an unowned reference’s value to nil, which means that unowned references are defined using nonoptional types. https://docs.swift.org/swift-book/LanguageGuide/AutomaticReferenceCounting.html
> Unlike a weak reference, however, an unowned reference is used when the other instance has the same lifetime or a longer lifetime. You indicate an unowned reference by placing the unowned keyword before a property or variable declaration. > An unowned reference is expected to always have a value. As a result, ARC never sets an unowned reference’s value to nil, which means that unowned references are defined using nonoptional types. https://docs.swift.org/swift-book/LanguageGuide/AutomaticReferenceCounting.html