찾다

 >  Q&A  >  본문

ios - Capturing 'self' strongly in this block is likely to lead to a retain cycle

错误ID

ListViewController.m:135:10: Capturing 'self' strongly in this block is likely to lead to a retain cycle

开了ARC

    [_tableView setPullToRefreshHandler:^{
        [self dataDidRefresh:nil];
    }];
高洛峰高洛峰2768일 전480

모든 응답(2)나는 대답할 것이다

  • PHP中文网

    PHP中文网2017-04-17 11:19:15

    你把self转换一下加上block字段之后就不会被retain了

    __block ViewController *controller = self;
    [_tableView setPullToRefreshHandler:^{
    [controller dataDidRefresh:nil];
    }];

    회신하다
    0
  • PHP中文网

    PHP中文网2017-04-17 11:19:15

    在ARC下不用__block 而是用 __weak 为了避免出现循环引用

    회신하다
    0
  • 취소회신하다