• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
ARC dealloc best pratice
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

ARC dealloc best pratice


  • Subject: ARC dealloc best pratice
  • From: Jonathan Mitchell <email@hidden>
  • Date: Fri, 06 Feb 2015 14:48:48 +0000

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 of these sorts of issues.
One development machine seemed impervious to an issue, another exhibited it with unfailing regularity.

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

	// remove any explicit bindings

	// unregister for notifications

	// set any non-weak delegates to nil (NSTableView et al)

	// invalidate any timers

}

In particular I have issues with non weak delegates and making sure that I get them set to nil.
I am not aware of anyway of automatically analyzing the source to help ensure that I haven’t missed something.

Are the following correct:

1. I presume that all the Cocoa framework objects such as NSTableView, NSPopOver etc that have non weak delegates need set to nil (in other words - AppKit doesn’t use ARC).
2. This applies even if I don’t have an outlet to say a NSTableView - which effectively means that I have to have outlets to all such objects.
3. At present I have not tried to ensure that NSWindow delegates (typically NSWindowController instances) are nil. Should I?

Jonathan











_______________________________________________

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


  • Follow-Ups:
    • Re: ARC dealloc best pratice
      • From: Jens Alfke <email@hidden>
    • Re: ARC dealloc best pratice
      • From: Kyle Sluder <email@hidden>
  • Prev by Date: Re: Is it possible for a WebView to not share sessions with Safari on Mac OS X?
  • Next by Date: Re: Is it possible for a WebView to not share sessions with Safari on Mac OS X?
  • Previous by thread: Re: Is it possible for a WebView to not share sessions with Safari on Mac OS X?
  • Next by thread: Re: ARC dealloc best pratice
  • Index(es):
    • Date
    • Thread