Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>It's impossible to say from the snippet you provided exactly what's going on, but this error generally means you've overreleased the object being messaged. My reading of your description and your code is that the parser is longer lived than the object you're setting as its delegate here:</p> <pre><code>- (void)parseXMLFileAtURL:(NSString *)URL { stories = [[NSMutableArray alloc] init]; NSURL *xmlURL = [NSURL URLWithString:URL]; parser = [[NSXMLParser alloc] initWithContentsOfURL:xmlURL]; [parser setDelegate:self]; [parser setShouldProcessNamespaces:NO]; [parser setShouldReportNamespacePrefixes:NO]; [parser setShouldResolveExternalEntities:NO]; [parser parse]; } </code></pre> <p>It's impossible to tell from the snippet you posted what the scope of the variable parser is. I'm suspecting it's a global variable or otherwise longer-lived than the delegate. I suspect this, because I see that you're setting the 'self object' to be the delegate, but never unsetting it, and the fact that the erroneous message is conformsToProtocol: hints that this might be the issue, because NSXMLParser will undoubtedly call that before attempting to call any delegate methods. When this object is going away, it needs to relinquish it's role as the delegate of the NSXMLParser instance by calling:</p> <pre><code>[parser setDelegate: nil]; </code></pre> <p>If the parser is, in fact, global or otherwise shared, then you should also be careful about recreating it on every call to parseXMLFileAtURL: without releasing prior values. If it's an iVar on the object itself, you still need to be sure and clear the delegate and release and clear the iVar when your object goes away (i.e. in dealloc). </p> <p>But again, it's impossible to be sure based on the snippet you've posted.</p>
 

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