嵌套块和对self的引用 [英] Nested blocks and references to self
本文介绍了嵌套块和对self的引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个块,其中我使用 self
所以我声明了对self的弱引用:
I have a block wherein I use self
so I declare a weak reference to self:
__weak MyClass *weakSelf = self;
现在我的问题:
-
我在定义
weakSelf
时遇到错误,我不明白这应该是什么意思。:
I get an error where I define
weakSelf
and I don't understand what this should mean.:
无法在自动变量上指定弱属性
weak attribute can not be specified on an automatic variable
在我的块中,我传递 weakSelf
到另一个区块,我不确定我现在是否必须再次做同样的事情:
Inside my block I pass weakSelf
to another block and I am not sure if I now have to do the same thing again like so:
__weak MyClass *weakWeakSelf = weakSelf;
然后将 weakWeakSelf
传递给该区块?
And then pass weakWeakSelf
to that block?
推荐答案
这很有可能发生在你瞄准iOS 4时你应该把它改成
This is most likely occurring as you are targeting down to iOS 4. You should change it to be
__unsafe_unretained MyClass *weakWeakSelf = weakSelf;
这篇关于嵌套块和对self的引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文