NSXMLParserDelegate memory issues
I'm running my app through Instruments, and every time the following setup causes a memory leak (apparently). I can't see an issue with this.
WeatherParser.h:
...
{
NSMutableDictionary *results;
}
@property (nonatomic, retain) NSMutableDictionary *results;
WeatherParser.m
- (void)parserDidStartDocument:(NSXMLParser *)parser
{
self.开发者_开发技巧results = [[NSMutableDictionary alloc] init];
}
...add values to results
- (void)dealloc
{
self.results = nil;
[self.results release];
[super dealloc];
}
Would greatly appreciate any observations.
Swap these around to read:
[self.results release];
self.results = nil;
you were calling the release on the nil object not on the results array.
精彩评论