views:

58

answers:

1

I have been using an RSS reader code example but have found a leak in the parser.

here's the code...

-(BOOL)fetchAndParseRss{
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

     [UIApplication sharedApplication].networkActivityIndicatorVisible = YES;

     //To suppress the leak in NSXMLParser
     [[NSURLCache sharedURLCache] setMemoryCapacity:0];
     [[NSURLCache sharedURLCache] setDiskCapacity:0];

     NSURL *url = [NSURL URLWithString:@"http://www.bnp.org.uk/?q=rss.xml"];
     BOOL success = NO;
     NSXMLParser *parser = [[NSXMLParser alloc] initWithContentsOfURL:url];
     [parser setDelegate:self];
     [parser setShouldProcessNamespaces:YES];
     [parser setShouldReportNamespacePrefixes:YES];
     [parser setShouldResolveExternalEntities:NO];
     success = [parser parse];
     [parser release];
     [pool drain];
     return success;
}

Can you help?

+1  A: 

NSXMLParser has a leak, is a bug from Apple. Bug #6469143. I don't think they have solved in iOS4. (At least not in the Simulator) Please see this: http://stackoverflow.com/questions/1598928/nsxmlparser-leaking

nacho4d
Thanks for that. Although there must be times when NSXMLParser is okay, the XML Performance test app on the Dev centre works okay.Any way I have found a great ready made RSS Parser from a great guy named Michael Waterfall at http://github.com/mwaterfall/MWFeedParser it works straight out of the box. So many thanks to Michael.
Stuart