开发者

Iphone Leaks NSString

开发者 https://www.devze.com 2022-12-27 14:43 出处:网络
I have leaks in the following code : NSString * string; - (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)str{

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号