正文
block中self关键字的使用-防止self 被retain一次
小程序:扫一扫查出行
【扫一扫了解最新限行尾号】
复制小程序
【扫一扫了解最新限行尾号】
复制小程序
在代码块中使用对象的成员时(成员变量是属性strong,MRC估计是retain时效果一样,使用方法时也一样):
警告:
capturing self strongly in this block is likely to lead to a retain cycle
意思应该是block会retain一次,所以使用前最好 __block MyClass* bObject = self;
__block KKHomePageVC* bObject = self;
[_table addLegendHeaderWithRefreshingBlock:^{ //[_table.header endRefreshing]; [bObject requestData];
[bObject requestARlist]; }];