Re: ARC dealloc best pratice
Re: ARC dealloc best pratice
- Subject: Re: ARC dealloc best pratice
- From: Sean McBride <email@hidden>
- Date: Tue, 10 Feb 2015 16:20:21 -0500
- Organization: Rogue Research Inc.
On Fri, 6 Feb 2015 12:46:44 -0800, Jens Alfke said:
>Come to think of it, I'm surprised that AppKit delegates are still
>unsafe-unretained. Why haven't these been converted to safe weak
>references yet?
The 'why' has been answered, but worse it's not even clear sometimes what a delegate's situation is. Take NSTableView.h in the 10.10 SDK:
-------------
/* Get and set the delegate. The delegate can implement methods in the protocol NSTableViewDelegate. All delegate methods are optional. The delegate is a weak reference (non retained) in non garbage collected applications. Under garbage collected apps, it is a strong reference. The default value is 'nil'.
*/
- (void)setDelegate:(id <NSTableViewDelegate>)delegate;
- (id <NSTableViewDelegate>)delegate;
-------------
So based on Greg saying "We prefer to reserve the term 'weak' for safe zeroing weak." I guess for NSTableView there's no need to nil the delegate. OTOH, my experience converting my GC app to ARC says the exact opposite. Without clearing the delegate to nil in say windowWillClose, I get sporadic crashes.
What's the true situation for NSTableView?
Cheers,
--
____________________________________________________________
Sean McBride, B. Eng email@hidden
Rogue Research www.rogue-research.com
Mac Software Developer Montréal, Québec, Canada
_______________________________________________
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