UIView的動畫block不會造成循環引用的原因就是,這是個類方法,當前控制器不可能強引用一個類,所以循環無法形成。
不需要,之所以需要弱引用本身,是因為怕對象之間產生循環引用,引起程序的崩潰!
所謂“引用循環”是指雙向的強引用,所以那些“單向的強引用”(block 強引用 self )沒有問題,比如這些:
1. [UIView animateWithDuration:duration animations:^{
[self.superview layoutIfNeeded];
}];
2. [[NSOperationQueue mainQueue] addOperationWithBlock:^{
self.someProperty = xyz;
}];
3. [[NSNotificationCenter defaultCenter] addObserverForName:@"someNotification"
object:nil
queue:[NSOperationQueue mainQueue]
usingBlock:^(NSNotification * notification) {
self.someProperty = xyz;
}];