views:

162

answers:

1

Hello,

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!

+5  A: 

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.

pix0r
The only catch is threads — autorelease pool stacks are per-thread.
Chuck