2014年9月3日水曜日

ワーニング Capturing 'self' strongly in this block is likely to lead to a retain cycle

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

こんなエラーが出てしまった。

    [oPageView setViewControllers:nextPage direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:^(BOOL finished) {
        [oTableView scrollToRowAtIndexPath:iPagePath atScrollPosition:UITableViewScrollPositionTop animated:YES];

    }];


Blockの中にインスタント変数を参照するとワーニングになります。

    __block UITableView *tablViewself = oTableView;
    [oPageView setViewControllers:nextPage direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:^(BOOL finished) {
        [tablViewself scrollToRowAtIndexPath:iPagePath atScrollPosition:UITableViewScrollPositionTop animated:YES];
    }];


こんな感じで、変数を外だしにするとOKです。

0 件のコメント:

コメントを投稿