Re: NSTableView is messaging zombie delegate
Re: NSTableView is messaging zombie delegate
- Subject: Re: NSTableView is messaging zombie delegate
- From: Jens Alfke <email@hidden>
- Date: Fri, 06 May 2016 13:28:10 -0700
> On May 6, 2016, at 1:03 PM, Matthew LeRoy <email@hidden> wrote:
>
> My understanding is that NSTableView's delegate is a zeroing weak reference
Are you sure? Historically it’s been unsafe_unretained — in the old days before weak references or ARC, the view never retained nor released the delegate. The type of crash you’re having was a not-uncommon bug.
Apple may have upgraded the property to a proper zeroing weak reference, but I can’t tell from the docs. They simply say "In a managed memory environment, the table view maintains a weak reference to the delegate (that is, it does not retain the delegate).” I’m assuming ARC counts as “managed”, but that sentence does not include the word “zeroing”…
I would play it safe and explicitly set the table view’s delegate to nil when tearing down the window. I usually do this in the windowWillClose delegate method.
—Jens
_______________________________________________
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