Re: NSTableView is messaging zombie delegate
Re: NSTableView is messaging zombie delegate
- Subject: Re: NSTableView is messaging zombie delegate
- From: Matthew LeRoy <email@hidden>
- Date: Sun, 08 May 2016 19:19:26 +0000
- Thread-topic: NSTableView is messaging zombie delegate
>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
Good point. I had been doing so much reading about delegates, weak and zeroing weak references, I failed to notice that the docs (and NSTableView.h) only say “weak reference” — no “zeroing”.
Unfortunately, setting the table view’s delegate to nil during tear-down (either in -windowWillClose: or in NSViewController’s -dealloc) doesn’t seem to fix the issue. I still get random but regularly reproducible crashes, with the same stack trace.
Any other ideas?
Matt
_______________________________________________
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