What is the scope of (nested) autorelease pools?

怎甘沉沦 提交于 2019-12-12 12:18:59

问题


I'm creating an autorelease pool in a for loop (in method A). At each iteration of the loop, I'm calling another method (method B). Method B returns an autoreleased object to Method A. If I drain the pool within the for loop in Method A, will that release the objects sent from Method B?

Thanks!


回答1:


Yes - any time an object is sent -autorelease, it's added to the highest level autorelease pool. As long as you aren't creating any new autorelease pools in method B or further down the call stack, method A's pool should be the highest level pool.



来源:https://stackoverflow.com/questions/1400826/what-is-the-scope-of-nested-autorelease-pools

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!