objective-c – 是否是Block_copy递归?

objective-c – 是否是Block_copy递归?,第1张

概述我有一些代码基本上归结为: -(void)doSomethingWithBlock:(BlockTypedef)block{ [Foo doSomethingElseWithBlock:^() { block(); }];} Foo doSomethingElseWithBlock:在它接收到的块上调用Block_copy和Block_release.这在外部范 我有一些代码基本上归结为:

-(voID)doSomethingWithBlock:(BlockTypedef)block{    [Foo doSomethingElseWithBlock:^() {        block();    }];}

Foo doSomethingElseWithBlock:在它接收到的块上调用Block_copy和Block_release.这在外部范围还是必需的,还是内部的Block_copy会处理这个?

解决方法 我引用了苹果开发者文档网站上的 Blocks Programming Topics指南:

When you copy a block,any references to other blocks from within that block are copIEd if necessary—an entire tree may be copIEd (from the top). If you have block variables and you reference a block from within the block,that block will be copIEd.

When you copy a stack-based block,you get a new block. If you copy a heap-based block,however,you simply increment the retain count of that block and get it back as the returned value of the copy function or method.

总结

以上是内存溢出为你收集整理的objective-c – 是否是Block_copy递归?全部内容,希望文章能够帮你解决objective-c – 是否是Block_copy递归?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1026771.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-23
下一篇 2022-05-23

发表评论

登录后才能评论

评论列表(0条)

保存