Update : I edited the code, but the problem persists ...
Hi everyone,
this is my first post here - I found this place a great source for solving many of my questions. Usually I try my best to fix things on my own, but this time I really don’t know what will go wrong, so I hope someone can help me.
I am creating an iPhone application that parses a couple of xml files using TouchXML. I have an XMLParser class that takes care of loading and parsing the results. I get memory leaks when I parse an xml file more than once with the same XMLParser instance. Here is one of the parsing fragments (only the corresponding part):
for(int counter = 0; counter < [item childCount]; counter++) {
CXMLNode *child = [item childAtIndex:counter];
if([[child name] isEqualToString:@"PRODUCT"])
{
NSMutableDictionary *product = [[NSMutableDictionary alloc] init];
for(int j = 0; j < [child childCount]; j++) {
CXMLNode *grandchild = [child childAtIndex:j];
if([[grandchild stringValue] length] > 1) {
NSString *trimmedString = [[grandchild stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
[product setObject:trimmedString forKey:[grandchild name]];
}
}
switch (categoryId) {
case 0:
[self.mobil addObject: product];
break;
case 1:
[self.allgemein addObject: product];
break;
case 2:
[self.besitzeIch addObject: product];
break;
case 3:
[self.willIch addObject: product];
break;
default:
break;
}
[product release];
}
}
, xml, , (NSCFString/NSCFDictionary).
CXMLNode.m, :
theStringValue = [NSString stringWithUTF8String:(const char *)theXMLString];
if ( _node->type != CXMLTextKind )
xmlFree(theXMLString);
}
return(theStringValue);
, , , , - ?
, !