What is the proper way to avoid Retain Cycle while using blocks

前端 未结 4 1778
有刺的猬
有刺的猬 2020-12-05 21:16

What is the proper way to add objects in NSMutableArray which is strongly defined by property.

[tapBlockView setTapBlock:^(UIImage* image) {
   [self.myImage         


        
4条回答
  •  粉色の甜心
    2020-12-05 21:51

    Your second and third ones appear correct. The second one works because you did not create a copy of the array, so that still points to the original one. The third one works because the reference to self is weak.

提交回复
热议问题