IOS中block循环引用现象:
例如:
block循环引用.png
判断方法:
//调用了dealloc方法就说明self被释放了,否则说明self在block里被循环引用了
-(void)dealloc
{
NSLog(@"%s",__func__);
}
解决方法:
//弱引用self
__weak typeof(self) weakself = self;
item.operation = ^ {
...
[weakself presentViewController:... animated:... completion:...];
...
}
网友评论