Re: NSXMLParser frees itself on error?
Re: NSXMLParser frees itself on error?
- Subject: Re: NSXMLParser frees itself on error?
- From: "Stephen J. Butler" <email@hidden>
- Date: Mon, 4 May 2009 13:31:31 -0500
On Fri, May 1, 2009 at 11:18 AM, Jesper Storm Bache <email@hidden> wrote:
> I have not used NSXMLParser, but as far as I can tell from your email,
> cleanupShowParsing is called in response to a call to the parser delegate.
> In that case, you should not release the parser (because it is calling your
> delegate and is on the stack).
> Try using autorelease instead.
That could also be dangerous. What if the parser sets up its own
autorelease pool while walking the XML document? You could have a
situation like this:
- (void) parse {
[self doSomething];
while (notDone) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[delegate callbackMethod];
[pool drain];
}
[self doSomethingMore];
}
What you're suggesting would put the parser into the inner autorelease pool!
I still maintain that it's never safe to release/autorelease an object
from inside one of it's delegate calls. If it works at all, you're
implicitly relying on an implementation detail that's subject to
change.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden