views:

83

answers:

1

Hi, I have leaks in the following code :

NSString * string;
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)str{
   string = [NSString stringWithFormat:@"%@", str];
}

- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName
  namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName {

   NSString * value = [string stringByReplacingOccurrencesOfString:@"\n" withString:@""];

}

But I don't understand what's the prob. Can you help me please? :s

A: 

Is the variable "string" always allocated from the autorelease pool? If not, then the first function could be suspect as "string", if it is already initialized with another string, is not released prior to the assignment. That would leak.

Kenny