- (void)main
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
self.workingArray = [NSMutableArray array];
self.descriptionString = [NSMutableString string];
NSXMLParser *parser = [[[NSXMLParser alloc] initWithData:dataToParse] autorelease];
[parser setDelegate:self];
[parser parse];
if (![self isCancelled])
{
// notify our AppDelegate that the parsing is complete
[self.delegate didFinishParsing:self.workingArray];
}
self.workingArray = nil;
self.descriptionString = nil;
self.dataToParse = nil;
[pool drain];
}
在此代码中,当我们在此行中调用[parser parse]
时,会发生内存泄漏问题。