• 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
Calling -retain inside -dealloc
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Calling -retain inside -dealloc


  • Subject: Calling -retain inside -dealloc
  • From: Andrew Garber <email@hidden>
  • Date: Sun, 26 Jun 2005 18:51:30 -0700

Hi all! Here's the situation:

I have a class variable, an NSMutableArray, which is storing instances
of the class. Why I'm doing this is quite complex, so I won't get into
the details. Whenever my object's -init is called, I call
NSMutableArray's -addObject, then release my object (so that the
retain count stays the same). Inside my object's -dealloc method, I
first retain self, then call NSMutableArray's -removeObject.
So, the retain count is zero when entering the -dealloc method, then
it gets incremented to 1, then it gets decremented back to zero.

Is there any risk that when the retain count drops to zero the second
time, -dealloc will be called again, causing an endless loop?


Thanks,

Andrew
 _______________________________________________
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

  • Follow-Ups:
    • Re: Calling -retain inside -dealloc
      • From: Andrew Garber <email@hidden>
    • Re: Calling -retain inside -dealloc
      • From: j o a r <email@hidden>
    • Re: Calling -retain inside -dealloc
      • From: Andrew Garber <email@hidden>
    • Re: Calling -retain inside -dealloc
      • From: Andrew Garber <email@hidden>
    • Re: Calling -retain inside -dealloc
      • From: mmalcolm crawford <email@hidden>
    • Re: Calling -retain inside -dealloc
      • From: Robert McNally <email@hidden>
    • Re: Calling -retain inside -dealloc
      • From: Fritz Anderson <email@hidden>
  • Prev by Date: Re: Moving other application windows
  • Next by Date: Re: Moving other application windows
  • Previous by thread: NSMetadataQueryResultContentRelevanceAttribute?
  • Next by thread: Re: Calling -retain inside -dealloc
  • Index(es):
    • Date
    • Thread