What is the use of unsafe_unretained attribute?

后端 未结 3 1039
忘了有多久
忘了有多久 2021-02-05 18:31

I know the definition of unsafe_unretained.

So i don\'t expect anyone to write its definition.

I want to know its use with example, and how it wor

3条回答
  •  后悔当初
    2021-02-05 19:06

    Previously to ARC, one might specify a delegate or other reference-to-parent property as assign to prevent retain cycles. With the introduction of ARC and the newer compilers you would instead use unsafe_unretained.

    So you use it any time you do not need ownership of the reference, and when you don't need or want to use the new weak reference type (which nulls out the reference when it is deallocated).

提交回复
热议问题