• 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
Re: ARC dealloc best pratice
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ARC dealloc best pratice


  • Subject: Re: ARC dealloc best pratice
  • From: Kyle Sluder <email@hidden>
  • Date: Fri, 06 Feb 2015 11:34:35 -0600

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
>
> 	// remove any explicit bindings
>
> 	// unregister for notifications
>
> 	// set any non-weak delegates to nil (NSTableView et al)
>
> 	// invalidate any timers
>
> }

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
invalidation all happens in -viewWillMoveToWindow: or another similar
place.

--Kyle Sluder
_______________________________________________

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: Steve Mills <email@hidden>
    • Re: ARC dealloc best pratice
      • From: Jonathan Mitchell <email@hidden>
    • Re: ARC dealloc best pratice
      • From: Jonathan Mitchell <email@hidden>
References: 
 >ARC dealloc best pratice (From: Jonathan Mitchell <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: ARC dealloc best pratice
  • Previous by thread: ARC dealloc best pratice
  • Next by thread: Re: ARC dealloc best pratice
  • Index(es):
    • Date
    • Thread