<分区>
Possible Duplicate:
What's the difference between sending -release or -drain to an Autorelease Pool?
我一直想知道 [pool release] 和 [pool drain] 之间的区别。
我们在IOS中创建基于View的应用时,使用[pool release]。
当我们在 MAX OS X 中创建命令行工具时,使用 [pool drain]。
为什么要以不同的方式使用它们?
标签 objective-c
<分区>
Possible Duplicate:
What's the difference between sending -release or -drain to an Autorelease Pool?
我一直想知道 [pool release] 和 [pool drain] 之间的区别。
我们在IOS中创建基于View的应用时,使用[pool release]。
当我们在 MAX OS X 中创建命令行工具时,使用 [pool drain]。
为什么要以不同的方式使用它们?
最佳答案
来自documentation :
In a garbage-collected environment, there is no need for autorelease pools. You may, however, write a framework that is designed to work in both a garbage-collected and reference-counted environment. In this case, you can use autorelease pools to hint to the collector that collection may be appropriate. In a garbage-collected environment, sending a drain message to a pool triggers garbage collection if necessary; release, however, is a no-op. In a reference-counted environment, drain has the same effect as release. Typically, therefore, you should use drain instead of release.
关于objective-c - [pool release] 和 [pool drain] 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7139420/