【发布时间】:2015-02-03 17:46:43
【问题描述】:
这是有问题的块。我想知道在块之外声明 strongSelf 是否会引入一个保留周期。在块外设置strongSelf的原因是我担心weakSelf会在完成块之前被释放。
__weak CollectionView *weakSelf = self;
CollectionView *strongSelf = weakSelf;
[self
performBatchUpdates:
^{
strongSelf->_cellSet = [strongSelf performDeletions:[strongSelf deletionsTowards:destinationSet from:strongSelf->_cellSet] from:strongSelf->_cellSet];
[(CollectionViewLayout *)strongSelf.collectionViewLayout setCellSet:strongSelf->_cellSet];
}
completion:
^(BOOL finished)
{
[strongSelf insertTowards:destinationSet];
}];
【问题讨论】:
-
是的,它会导致一个保留周期。您应该修复您的代码,以便在调用回调之前不会释放
self。
标签: objective-c