Re: Calling -retain inside -dealloc
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