Re: ARC dealloc best pratice

2015-02-11 Thread Steve Mills
On Feb 6, 2015, at 11:34:35, Kyle Sluder k...@ksluder.com wrote: Dealloc is too late for a lot of this stuff. I try to keep -dealloc as pure as possible; that is, -dealloc should only be concerned with memory management. Removing observers, unbinding, unregistering notifications, and timer

Re: ARC dealloc best pratice

2015-02-10 Thread Sean McBride
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

Re: ARC dealloc best pratice

2015-02-10 Thread Jonathan Mitchell
On 10 Feb 2015, at 21:20, Sean McBride s...@rogue-research.com wrote: 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

Re: ARC dealloc best pratice

2015-02-07 Thread Jonathan Mitchell
On 6 Feb 2015, at 17:34, Kyle Sluder k...@ksluder.com wrote: On Fri, Feb 6, 2015, at 08:48 AM, Jonathan Mitchell wrote: So I want to have a best practice template to follow in my dealloc. Dealloc is too late for a lot of this stuff. I try to keep -dealloc as pure as possible; that is,

Re: ARC dealloc best pratice

2015-02-06 Thread Alex Zavatone
Here's where I am confused. I thought you were running into problems on the Mac, but I see you mention iOS 5.1 and 6.0 while you mention that you are running into problems with NSViewController. If you were running into problems on iOS, I'd expect to see UIViewController, not

Re: ARC dealloc best pratice

2015-02-06 Thread Jonathan Mitchell
On 6 Feb 2015, at 17:34, Kyle Sluder k...@ksluder.com wrote: Dealloc is too late for a lot of this stuff. I try to keep -dealloc as pure as possible; that is, -dealloc should only be concerned with memory management. I agree that dealloc is far from perfect. What it does have going for it

Re: ARC dealloc best pratice

2015-02-06 Thread David Duncan
On Feb 6, 2015, at 12:46 PM, Jens Alfke j...@mooseyard.com wrote: On Feb 6, 2015, at 11:55 AM, Jonathan Mitchell jonat...@mugginsoft.com wrote: The tableView.delegate is not a zeroing weak ref - in the lingo of ARC it is unsafe_unretained I believe self can be deallocated leaving

Re: ARC dealloc best pratice

2015-02-06 Thread Jens Alfke
On Feb 6, 2015, at 11:55 AM, Jonathan Mitchell jonat...@mugginsoft.com wrote: The tableView.delegate is not a zeroing weak ref - in the lingo of ARC it is unsafe_unretained I believe self can be deallocated leaving tableView.delegate as a dangling pointer. This is still a weak

Re: ARC dealloc best pratice

2015-02-06 Thread Jonathan Mitchell
On 6 Feb 2015, at 20:46, Jens Alfke j...@mooseyard.com wrote: 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? I presume that AppKIt (all of it?) is not compiled using ARC and hence doesn’t

Re: ARC dealloc best pratice

2015-02-06 Thread Jonathan Mitchell
On 6 Feb 2015, at 21:31, Greg Parker gpar...@apple.com wrote: 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? Some classes are incompatible with (safe zeroing) weak references. For

Re: ARC dealloc best pratice

2015-02-06 Thread Jens Alfke
On Feb 6, 2015, at 2:00 PM, Greg Parker gpar...@apple.com wrote: Swift adds unowned references. These references are non-retaining. They differ from weak references and unsafe unretained references: unowned references fail with a runtime error if you try to access the pointed-to object

Re: ARC dealloc best pratice

2015-02-06 Thread Greg Parker
On Feb 6, 2015, at 1:48 PM, Jonathan Mitchell jonat...@mugginsoft.com wrote: On 6 Feb 2015, at 21:31, Greg Parker gpar...@apple.com wrote: 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?

Re: ARC dealloc best pratice

2015-02-06 Thread Jonathan Mitchell
On 6 Feb 2015, at 17:34, Jens Alfke j...@mooseyard.com wrote: On Feb 6, 2015, at 6:48 AM, Jonathan Mitchell jonat...@mugginsoft.com wrote: // remove observers // unregister for notifications I have to confess I'm still not completely certain whether these are needed

Re: ARC dealloc best pratice

2015-02-06 Thread Greg Parker
On Feb 6, 2015, at 12:46 PM, Jens Alfke j...@mooseyard.com wrote: On Feb 6, 2015, at 11:55 AM, Jonathan Mitchell jonat...@mugginsoft.com wrote: The tableView.delegate is not a zeroing weak ref - in the lingo of ARC it is unsafe_unretained I believe self can be deallocated leaving

Re: ARC dealloc best pratice

2015-02-06 Thread Greg Parker
On Feb 6, 2015, at 3:27 PM, Jens Alfke j...@mooseyard.com wrote: On Feb 6, 2015, at 2:00 PM, Greg Parker gpar...@apple.com mailto:gpar...@apple.com wrote: Swift adds unowned references. These references are non-retaining. They differ from weak references and unsafe unretained

Re: ARC dealloc best pratice

2015-02-06 Thread Greg Parker
On Feb 6, 2015, at 1:18 PM, Jonathan Mitchell jonat...@mugginsoft.com wrote: On 6 Feb 2015, at 20:46, Jens Alfke j...@mooseyard.com wrote: 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?

Re: ARC dealloc best pratice

2015-02-06 Thread Jonathan Mitchell
On 6 Feb 2015, at 17:34, Jens Alfke j...@mooseyard.com wrote: On Feb 6, 2015, at 6:48 AM, Jonathan Mitchell jonat...@mugginsoft.com wrote: // remove observers // unregister for notifications I have to confess I'm still not completely certain whether these are needed under

ARC dealloc best pratice

2015-02-06 Thread Jonathan Mitchell
I have a mid sized (200+ nib files and associated NSView + NSWindow controllers) ARC enabled app. I have Zombie objects ON and have chased down a number of issues, most of which can be traced back to an incorrectly defined dealloc. My recent experiences have demonstrated the treacherous nature

Re: ARC dealloc best pratice

2015-02-06 Thread Kyle Sluder
On Fri, Feb 6, 2015, at 08:48 AM, Jonathan Mitchell wrote: So I want to have a best practice template to follow in my dealloc. At present the template looks like so. When I need a dealloc I paste this in and fill in the blanks - (void) dealloc { // remove observers //

Re: ARC dealloc best pratice

2015-02-06 Thread Jens Alfke
On Feb 6, 2015, at 6:48 AM, Jonathan Mitchell jonat...@mugginsoft.com wrote: // remove observers // unregister for notifications I have to confess I'm still not completely certain whether these are needed under ARC. I remember reading something about at least one of these being