Re: menu madness with retain count
Re: menu madness with retain count
- Subject: Re: menu madness with retain count
- From: Uli Kusterer <email@hidden>
- Date: Wed, 28 Apr 2010 00:05:07 +0200
On 27.04.2010, at 23:22, Gary L. Wade wrote:
> Calling -retainCount
> immediately before and after the -setDelegate call is pretty much the only
> way.
Nope. It'll only lead to pain and suffering. And false positives. What if setDelegate was implemented thus:
-(void) setDelegate: (id)dele
{
mDelegate = dele;
[self detachNewThreadSelector: @selector(useDelegateOnThread:) withObject: dele];
}
This will retain the delegate to hand it off to the other thread. Depending on how long that other thread takes and how good a day your scheduler has, the thread may be finished and mDelegate may contain a weak reference to the delegate, or the thread may take longer, and then your code looking at the retain count will think it was a strong reference.
There is no substitute to reading the documentation.
Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden