>On May 6, 2016, at 1:03 PM, Matthew LeRoy <mle...@minitab.com> 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 (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to