Embedded Autorelease Pools

Discussion in 'Mac Programming' started by Jordan72, Dec 28, 2005.

  1. macrumors member

    Nov 23, 2005
    Objects are automatically added to the auto release pool that is on the top of the stack, like objects that are returned from NSStrings and NSNumber class methods, -numberWithInt and -stringWithString.

    I have a situation where I want some objects that are created in a nested pool to be in added only to the outer pool.

    I don't want them added to the inner pool, even though I need to create them within in this pool. How do I create objects, but at the same time add them to a pool that is not currently at the top of the stack?
  2. thread starter macrumors member

    Nov 23, 2005
    I found the answer to my question, so I'm posting the answer.

    I retain the object, so it will last beyond the scope of the inner pool. And, I send an -addObject: message to the outer pool, where the argument is the object I'm adding to the pool.

Share This Page