NSAutoreleasePool在NSOperation主要? [英] NSAutoreleasePool in NSOperation main?
问题描述
+ [NSThread detachNewThreadSelector:toTarget:withObject:]
的说明文件:
对于非垃圾收集的应用程序,方法
aSelector
负责
为新分离的线程设置自动释放池,释放
。
For non garbage-collected applications, the method
aSelector
is responsible for setting up an autorelease pool for the newly detached thread and freeing that pool before it exits.
我的问题是,我需要创建自己的 NSAutoreleasePool
在我的覆盖 - [NSOperation main]
方法,或是创建 NSAutoreleasePool
处理 NSOperation
?
My question is, do I need to create my own NSAutoreleasePool
in my override of the -[NSOperation main]
method, or is the creation of the NSAutoreleasePool
handled by NSOperation
?
推荐答案
你正在定义一个自包含的工作,NSOperationQueue将在某些线程上执行,所以你负责管理该工作中的内存。
Yes, you do. You're defining a self-contained piece of work which the NSOperationQueue will execute on "some" thread, so you're responsible for managing memory in that work piece.
这篇关于NSAutoreleasePool在NSOperation主要?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!