Do we need to use __weak self inside UIAnimationBlocks in ARC?

后端 未结 3 1021
春和景丽
春和景丽 2020-12-08 01:28

Do we need to use __weak self inside UIAnimation Blocks as given below? Whether it will create retain cycle issue if we are not specifying self as weak?

[UIV         


        
3条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-08 01:50

    This is not a retain cycle. A retain cycle would be

    self -> block -> self
    

    In this case we have

    animation framework -> block
    block -> self
    

    where the first retain is only temporary - the block gets released when the animation ends. Even if a retain cycle happens, it will be only temporary and it won't prevent object deallocation.

提交回复
热议问题