Iphone Leaks NSString
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
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.
精彩评论