• 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: Jens Alfke <email@hidden>
  • Date: Fri, 06 Feb 2015 12:46:44 -0800

> On Feb 6, 2015, at 11:55 AM, Jonathan Mitchell <email@hidden> 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 reference, it's just unsafe (non-zeroing.) You're right that these need to be cleaned up manually.

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 problem is that there is, I believe, no way to accurately determine whether a or b is true in any particular instance!

It depends on the class. For example, NSURLConnection has a well-defined order in which it sends delegate messages, so it's possible to know when it's not going to send any more messages. But yeah, in a window's view hierarchy it's extremely unpredictable so it's important to zero out delegate references.

—Jens
_______________________________________________

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: Sean McBride <email@hidden>
    • Re: ARC dealloc best pratice
      • From: Greg Parker <email@hidden>
    • Re: ARC dealloc best pratice
      • From: Jonathan Mitchell <email@hidden>
    • Re: ARC dealloc best pratice
      • From: David Duncan <email@hidden>
References: 
 >ARC dealloc best pratice (From: Jonathan Mitchell <email@hidden>)
 >Re: ARC dealloc best pratice (From: Jens Alfke <email@hidden>)
 >Re: ARC dealloc best pratice (From: Jonathan Mitchell <email@hidden>)

  • Prev by Date: Re: ARC dealloc best pratice
  • Next by Date: Re: ARC dealloc best pratice
  • Previous by thread: Re: ARC dealloc best pratice
  • Next by thread: Re: ARC dealloc best pratice
  • Index(es):
    • Date
    • Thread