7

我对如何更改块内的实例变量感到很困惑。

接口文件(.h):

@interface TPFavoritesViewController : UIViewController {
    bool refreshing;
}

实施:

__weak TPFavoritesViewController *temp_self = self;
refreshing = NO;
[myTableView addPullToRefreshWithActionHandler:^{
    refreshing = YES;
    [temp_self refresh];
}];

正如您可能猜到的那样,当我尝试更改块内的刷新 ivar 时,我会收到一个保留周期警告。我将如何做到这一点而不会出错?

4

1 回答 1

6

Your assignment to refreshing is an implicit reference to self, it is shorthand for:

self->refreshing = YES;

hence the cycle warning. Change it to:

temp_self->refreshing = YES;
于 2012-08-01T04:43:10.753 回答