Objective C宏,用于轻松创建弱引用。
不再在代码块中存在retain循环。
只有两个宏,分别创建另一个弱引用或强引用。
WEAK(__self)
STRONG(__self)
WEAK(self);
void (^ block)() = ^{
// now you can use _self variable as weak reference
};
WEAK(self);
void (^ block)() = ^{
STRONG(_self);
// now you can use s_self variable as strong reference that is created from weak reference
};
WEAK(self);
[UIView animateWithDuration:0.25 animations:^{
_self.frame = CGRectMake(0.0f, 0.0f, 10.0f, 10.0f);
}];
WEAK(self);
[UIView animateWithDuration:0.25 animations:^{
STRONG(_self);
s_self->variable = 0;
}];