Discussion in 'iOS Programming' started by XcodeNewb, Mar 3, 2009.

  1. XcodeNewb macrumors member

    Feb 6, 2009
    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

    - (void)parserDidStartDocument:(NSXMLParser *)parser
    	myPool = [[NSAutoreleasePool alloc] init];
            /* Do some Stuff */
        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