using ARC, lifetime qualifier assign and unsafe_unretained

后端 未结 1 1748
伪装坚强ぢ
伪装坚强ぢ 2020-12-10 15:47

i\'m a little confused about these two qualifiers... With ARC instead of using weak (i.e. if I need support iOS 4) I can use unsafe_unretained los

相关标签:
1条回答
  • 2020-12-10 15:58

    Clang's technical specification of ARC goes into much more detail about how the qualifiers work.

    But, to answer your question: assign and __unsafe_unretained are not the same thing. assign is a property attribute that tells the compiler how to synthesise the property's setter implementation, while __unsafe_unretained is an ownership qualifier that tells ARC how to insert retain/release calls. But they are related: when declaring a property, assign implies __unsafe_unretained ownership.

    Prior to ARC, assign was the default property ownership qualifier; but with ARC enabled, the default for retainable object pointer types is strong. (For scalars and other pointer types, assign is still the default.)

    0 讨论(0)
提交回复
热议问题