> On Aug 29, 2016, at 6:39 AM, Andreas Falkenhahn <andr...@falkenhahn.com> 
> wrote:

> 
>> On 29.08.2016 at 02:10 Kyle Sluder wrote:
>> 
>> Delegates are different because they are often messaged in response to
>> various exogenous events. Some of these events might happen transiently
>> during window teardown, which is usually a time of massive fluctuation
>> in an app’s object graph. This is why -windowDidClose: is a good time to
>> nil out delegate properties that point back and the window controller
>> which ultimately owns the control.
> 
> So does this mean that this is potentially dangerous?
> 
>    [NSApp runModalForWindow:win];
>    [tableView setDelegate:nil];
>    [tableView setDataSource:nil];
>    [win release];
> 
> Should I move the "set to nil" calls to -windowDidClose instead?

Since you hold a strong reference to the window until after you clear out the 
delegate/dataSource backpointers, you know that the window cannot be 
reallocated until at least that point (but could be delayed to any arbitrary 
point in the future). So this approach is safe from window teardown causing the 
table view to message a zombie delegate.

--Kyle Sluder

> 
> -- 
> Best regards,
> Andreas Falkenhahn                            mailto:andr...@falkenhahn.com
> 
_______________________________________________

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