-(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递归?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)