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

前端 未结 4 1784
有刺的猬
有刺的猬 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:46

    Try a combination of the 2nd and 3rd.

    __weak id weakSelf = self;
    [tapBlockView setTapBlock:^(UIImage* image) {
        [weakSelf.myImageArray addObject:image];
    }
    

提交回复
热议问题