我有一个 NSOperation 的子类,我想做这样的事情:
@interface MyOperation : NSOperation...
MyOperation *myOperation = [[MyOperation alloc] init];
[myOperation setCompletionBlock = [^{
[myOperation doSomething]; // Do something with myOperation and other classes captured from original environment
[myOperation setCompletionBlock:nil]; // Manually setting to nil avoid retain cycles;
} copy]; <- is this "copy" needed here?
所以我对这段代码的问题是标题问题:
我是否需要复制 (Block_copy()) 我传递给 setCompletionBlock: 的块:或者 NSOperation 会为我做这件事?