autoreleasepool

Discussion in 'iPhone/iPad Programming' started by XcodeNewb, Mar 3, 2009.

  1. macrumors member

    Joined:
    Feb 6, 2009
    #1
    Do autoreleasepool's carry over from one method to another?

    I am creating an autorelesae pool in one method and then using autorelease in another method and I am assuming that the objects are being added to my pool but I do not know how to tell for sure.

    Here is some sampe code

    Code:
    - (void)parserDidStartDocument:(NSXMLParser *)parser
    
    	myPool = [[NSAutoreleasePool alloc] init];
    
            /* Do some Stuff */
    }
    
    -(void)myOtherMethod
    {
        contentOfCurrentElement = [[[NSMutableString alloc] init] autorelease];
    }
    
    
    - (void)parserDidEndDocument:(NSXMLParser *)parser {
    	[myPool release];
    }
    
    Is it safe to say that "contentOfCurrentElement" is being added to myPool's pool, and is released when the [myPool release] is called?

    Or does myPool only hold objects that are autoreleased in the parserDidStartDocument method?

    Thanks for the insight.
     

Share This Page