我们有这样的结构(ARC代码):
// load an object into an ivar using a block
self->objectLoader = [MyObject loadOnSuccess:^(MyObject *object) {
// reference self from the block, so self is retained
self->_object = object;
// try to dereference the loader
self->objectLoader = nil;
}
问题是对象永远不会释放,因为self永远不会完全释放。如果我用weakSelf版本替换self,则对象将成功释放。
是否有办法使ivar无效,以便释放它“保持”的块并且可以解除分配对象?