The static analyzer detects a leak in this block of code (in particular, a link with a copy in it):
- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName { if ([elementName isEqualToString:@"item"]) { [elements setObject:title forKey:@"title"]; [elements setObject:date forKey:@"date"]; [elements setObject:summary forKey:@"summary"]; [elements setObject:link forKey:@"link"]; [posts addObject:[elements copy]]; } }
I tried to free the copied object, but I still get a warning. Did I miss something?
thank
You have created a new copy that you are not releasing.
This returns a new object elementswith ref 1, for which you are responsible for the release, because you just created a copy:
elements
[elements copy];
posts, . , ref 1 2, .
posts
[posts addObject:[elements copy]];
posts release, 1, elements , .
release
copy , :
copy
[post addObject:elements];
, :
, .
, ?
[posts addObject:[elements copy]]; [elements release];
, , , - , copy, , posts. : .
, , , , , ; , . elements, .
elements a removeAllObjects; , .
removeAllObjects
elements, XML. "elements" . "feedItemProperties" .
feedItemProperties
Source: https://habr.com/ru/post/1732807/More articles:Hibernation: more than one relationship using a single connection column - javaWhy does EntLib caching application block use the wrong configuration file - c #WYSIWYG editor for Rails with copy package integration - ruby-on-railsОтображение отношения состава и зависимости в диаграммах классов с использованием Visual Studio 2008 - visual-studio-2008What do you do with ModelView files growing in an MVVM application? - wpfНевозможно повлиять на содержимое UITextView с помощью initWithCoder - iosReading values from a file and assigning it to a variable in batch script - windowsHow to prevent Qt buttons from appearing in a separate frame? - pythonremoving all elements from an xml file except the root element of C # - c #How to redefine the verification call in activerecord in gem? - ruby | fooobar.comAll Articles