Re: removeFromSuperview crash - please help
Re: removeFromSuperview crash - please help
- Subject: Re: removeFromSuperview crash - please help
- From: Matt Neuburg <email@hidden>
- Date: Sat, 06 Nov 2004 12:49:36 -0800
On Sat, 6 Nov 2004 10:46:54 -0800 (PST), Keith Blount
<email@hidden> said:
>it seems that if I retain the subview before
>callling removeFromSuperview (or if I never release it
>after adding it using addSubview: in the first place),
>it will never be released. But if I release everything
>in the proper place (ie. release the NoteCard after it
>is added as a subview using addSubview:, relying on
>its parent to retain it), then on calling
>removeFromSuperview, release will be called too many
>times and cause the app to crash.
(1) I always all setNeedsDisplay:NO on a view before I remove it from the
superview. Call it superstition if you like.
(2) I add and remove things from superviews like crazy and I don't crash. I
even call [self removeFromSuperview]. So I don't see what you're doing
wrong. I presume that that is because what you are doing wrong is somewhere
else, not in the code you showed. :) What happens if you retain the
superview, autorelease it, and remove it from the superview? My idea here is
that you will thus postpone the release until after the event is over.
However, that's just a guess. The real problem is that you say you crash but
you don't say why. I'm wondering whether it's because something *else*
besides the superview has a reference to the subview and tries to access it
after it has been released. m.
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide
<http://www.amazon.com/exec/obidos/ASIN/0596005571/somethingsbymatt>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden