tags:

views:

20

answers:

1

i have this

 NSXMLParser *xmlParserf = [[NSXMLParser alloc] initWithContentsOfURL:url];
    //  NSLog(@"URL%@",urlf);
    //Initialize the delegate.

    XMLParser *parserf = [[XMLParser alloc] initXMLParser];
    [xmlParserf setDelegate:parserf];

    //Start parsing the XML file.

    BOOL successs = [xmlParserf parse];

    [UIApplication sharedApplication].networkActivityIndicatorVisible = YES;

    NSLog(@" this xml  is %d",[xmlParserf retainCount]);// getting error
    NSLog(@" this paaat is %d",[parserf retainCount]);// getting error

    if(successs)
    {
        NSLog(@"ZONE IS PARSED");
        [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
    }
    else
    {
        NSLog(@"NOT PARSED!!!");
    }

    //[xmlParserf release]; not working
            //[parserf release];

now i dont know when to release those objects these are running in some threads

+1  A: 

everytime you alloc (or copy), you must either release or autorelease.

In this case:

NSXMLParser *xmlParserf = [[[NSXMLParser alloc] initWithContentsOfURL:url] autorelease];

and

XMLParser *parserf = [[[XMLParser alloc] initXMLParser] autorelease];

It means that you keep it in memory at least until the end of the current function. If other objects hang on to it (i.e. retain it) then the objects stay in memory, until they are released (by those other objects).

mvds
thank you sir :-)
ram