为什么 Apple 将 block 设计为在堆栈上分配,除非被复制?这样的行为有什么好处?为什么不让它表现得像一个普通的 NSObject - alloc-init 它并自动进入堆?
最佳答案
The reason why blocks are placed on the stack by default is speed. In the common case where the lifetime of the block is less than that of the stack function that contains it, this is a very good optimisation.
http://www.cocoawithlove.com/2009/10/how-blocks-are-implemented-and.html
关于ios - 为什么 block 被设计为在堆栈上分配,除非被复制?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16471988/