dispatch_block_cancel是否释放调度块



如果没有ARC,dispatch_block_cancel是释放调度块还是需要手动释放?

dispatch_block_t work = dispatch_block_create(0, ^{
//...
});
dispatch_block_cancel(work);    // Is work released here?
Block_release(work);            // Or it need to be released?

假设dispatch_block_cancel释放了块,那么这两种情况之间有什么区别?

// Case 1
dispatch_block_t work = dispatch_block_create(0, ^{
//...
});
dispatch_block_cancel(work);

// Case 2
dispatch_block_t work = dispatch_block_create(0, ^{
//...
});
Block_release(work);

取消对内存管理没有影响。您调用了dispatch_block_create,其中包含单词";创建"这意味着你有责任释放内存。什么也帮不了你。

最新更新