我是否需要不断地声明弱引用来打破块内部的块的保留周期?
__weak typeof(self) weakSelf = self;
[self setMyBlock:^(id obj, NSUInteger idx, BOOL *stop) {
typeof(self) strongSelf = weakSelf;
[strongSelf doSomething];
[strongSelf setMyBlock:^(id obj, NSUInteger idx, BOOL *stop) {
//do I need to create another weak reference to strongSelf for this block?
[strongSelf doSomething];
}];
}];
strongSelf
是否为nil。在这种情况下没有什么区别,但通常是一个好主意。 - mattNSArray
方法enumerateObjectsUsingBlock:
。 - zaph