Note that there are some explanatory texts on larger screens.

plurals
  1. POMemory leak NSXMLParser
    primarykey
    data
    text
    <p>My NSXMLParser is leaking and I don't know why! Instrument is saying, in the extended details, that the source is 100% from <code>[Parser parse]</code>;</p> <p>Picture: <a href="http://i.stack.imgur.com/EMSID.png" rel="nofollow">Instruments leaks </a></p> <p>This is my code for allocating and releasing the NSXMLParser:</p> <pre><code>NSURL *xmlURL = [NSURL URLWithString:@"http://www.website.com/link.xml"]; NSData * dataXml = [[NSData alloc] initWithContentsOfURL:xmlURL]; Parser = [[NSXMLParser alloc] initWithData:dataXml]; [dataXml release]; Parser.delegate = self; [Parser parse]; [Parser release]; </code></pre> <p>The delegate methods </p> <pre><code> //Standard function parser: reading open tag - (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict{ currentElement = elementName; if ([elementName isEqualToString:@"item"]) { xmlArray = [[NSMutableDictionary alloc] init]; } } //Standard function parser: reading string - (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string{ if ([currentElement isEqualToString:@"created_time"]){ valueKey = [xmlArray valueForKey:currentElement]; if(nil != valueKey) { valueKey = [valueKey stringByAppendingString:string]; }else { valueKey = string; } [xmlArray setObject:valueKey forKey:currentElement]; } if ([currentElement isEqualToString:@"message"]){ valueKey = [xmlArray valueForKey:currentElement]; if(nil != valueKey) { valueKey = [valueKey stringByAppendingString:string]; }else { valueKey = string; } [xmlArray setObject:valueKey forKey:currentElement]; } if ([currentElement isEqualToString:@"picture"]){ valueKey = [xmlArray valueForKey:currentElement]; if(nil != valueKey) { }else { valueKey = string; } [xmlArray setObject:valueKey forKey:currentElement]; } } //Standard function parser: reading close tag - (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName{ if ([elementName isEqualToString:@"item"]) { Post *newPost = [[Post alloc] init]; newPost.created_time = [xmlArray objectForKey:@"created_time"]; newPost.message = [xmlArray objectForKey:@"message"]; newPost.picture = [xmlArray objectForKey:@"picture"]; [containerArray addObject:newPost]; [xmlArray release]; [newPost release]; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload