• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: removeFromSuperview crash - please help (solved)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: removeFromSuperview crash - please help (solved)


  • Subject: Re: removeFromSuperview crash - please help (solved)
  • From: Keith Blount <email@hidden>
  • Date: Sat, 6 Nov 2004 15:40:35 -0800 (PST)

Many thanks for your reply. After thinking about what
you said, I decided to write a quick test class that
only contained the fundamentals of the code from my
class, and doing this I was able to isolate my
problem. You were right - the problem lay outside the
code I posted. In the override of the dealloc method
for my NoteCard class, I was trying to release the
text view - but as this was only retained as a
subview, I forgot that it would have been released
automatically when the NoteCard view was sent a
release message, so I didn't need to release it again
in the overridden dealloc method. Once I got rid of
this, I NSLogged both the dealloc methods for my
NoteCard view and my text view, and both were
deallocated correctly on removeFromSuperview with no
crashes - whew!

Many thanks again,
Keith


--- Matt Neuburg <email@hidden> wrote:

> 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 you Yahoo!?
Check out the new Yahoo! Front Page.
www.yahoo.com


 _______________________________________________
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

References: 
 >Re: removeFromSuperview crash - please help (From: Matt Neuburg <email@hidden>)

  • Prev by Date: Re: Newbie: cannot find method
  • Next by Date: Re: Hiring a coder to squash a bug?
  • Previous by thread: Re: removeFromSuperview crash - please help
  • Next by thread: Mail Plug-in
  • Index(es):
    • Date
    • Thread