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

Re: Calling -retain inside -dealloc


  • Subject: Re: Calling -retain inside -dealloc
  • From: Robert McNally <email@hidden>
  • Date: Sun, 26 Jun 2005 20:19:05 -0700

If you just want a weak reference in your NSMutableArray, then you should look into wrapping your instance pointer in an NSValue. See NSValue valueWithNonretainedObject:

>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

--
______________________________________________________________________
Robert McNally, Arciem Engineering             <http://www.arciem.com>
                                                          626/963-7760
 _______________________________________________
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: Bob Ippolito <email@hidden>
References: 
 >Calling -retain inside -dealloc (From: Andrew Garber <email@hidden>)

  • Prev by Date: Re: Calling -retain inside -dealloc
  • Next by Date: Re: Calling -retain inside -dealloc
  • Previous by thread: Re: Calling -retain inside -dealloc
  • Next by thread: Re: Calling -retain inside -dealloc
  • Index(es):
    • Date
    • Thread