• 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: Cleaning up weak references ( was Re: Odd Crash when adding table columns manually )
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cleaning up weak references ( was Re: Odd Crash when adding table columns manually )


  • Subject: Re: Cleaning up weak references ( was Re: Odd Crash when adding table columns manually )
  • From: Eric Gorr <email@hidden>
  • Date: Thu, 20 Jan 2011 19:58:17 -0500

On Jan 20, 2011, at 4:56 PM, Sean McBride wrote:

> On Thu, 20 Jan 2011 13:27:35 -0800, Corbin Dunn said:
>
>>> For a specific example, check out the AnimatedTableView sample code
>> from Apple.  The ATColorTableController class is a datasource for the
>> table, but it's dealloc looks like:
>>>
>>> - (void)dealloc
>>> {
>>>  [_colorList release];
>>>  [_colorNames release];
>>>  [_window release];
>>>  [super dealloc];
>>> }
>>>
>>> Based on my current understanding, the table controller's dealloc
>> (above) should be setting the table datasource and delegate to nil.
>> Correct? If so, I will file a bug.
>>
>> I wrote that sample, and gave the WWDC talk based on it a few years ago.
>> I also "own" NSTableView.
>>
>> Yes, please do file a bug. The sample should set the delegate/datasource
>> to nil, as it is good practice to do so, and we can update the sample.
>
> In the case of garbage collected-only mode, do I assume correctly that
> such setting to nil is not needed?


I thought this might be of interest....Mike Ash writes:

-----
http://www.mikeash.com/pyblog/friday-qa-2010-07-16-zeroing-weak-references-in-objective-c.html
If you're using garbage collection in Objective-C, then good news! The Objective-C garbage collector already supports zeroing weak references using the type modifier __weak. You can just declare any instance variable like so:

    __weak id _foo;
And it's automatically a zeroing weak reference. The compiler takes care of emitting the appropriate read/write barriers so that access is always safe.
-----



_______________________________________________

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

References: 
 >Odd Crash when adding table columns manually (From: Eric Gorr <email@hidden>)
 >Re: Odd Crash when adding table columns manually (From: Peter Lübke <email@hidden>)
 >Re: Odd Crash when adding table columns manually (From: Eric Gorr <email@hidden>)
 >Re: Odd Crash when adding table columns manually (From: Keary Suska <email@hidden>)
 >Re: Odd Crash when adding table columns manually (From: Eric Gorr <email@hidden>)
 >Re: Odd Crash when adding table columns manually (From: Eric Gorr <email@hidden>)
 >Re: Odd Crash when adding table columns manually (From: Lee Ann Rucker <email@hidden>)
 >Re: Odd Crash when adding table columns manually (From: Eric Gorr <email@hidden>)
 >Re: Odd Crash when adding table columns manually (From: Corbin Dunn <email@hidden>)
 >Re: Odd Crash when adding table columns manually (From: Graham Cox <email@hidden>)
 >Re: Odd Crash when adding table columns manually (From: Eric Gorr <email@hidden>)
 >Re: Odd Crash when adding table columns manually (From: Graham Cox <email@hidden>)
 >Re: Odd Crash when adding table columns manually (From: Eric Gorr <email@hidden>)
 >Cleaning up weak references ( was Re: Odd Crash when adding table columns manually ) (From: Eric Gorr <email@hidden>)
 >Re: Cleaning up weak references ( was Re: Odd Crash when adding table columns manually ) (From: Kyle Sluder <email@hidden>)
 >Re: Cleaning up weak references ( was Re: Odd Crash when adding table columns manually ) (From: Eric Gorr <email@hidden>)
 >Re: Cleaning up weak references ( was Re: Odd Crash when adding table columns manually ) (From: "Sean McBride" <email@hidden>)

  • Prev by Date: Re: printing a different representation than what is on the screen
  • Next by Date: Re: iOS Pass NSManagedObjectContext from my app delegate
  • Previous by thread: Re: Cleaning up weak references ( was Re: Odd Crash when adding table columns manually )
  • Next by thread: Re: Cleaning up weak references ( was Re: Odd Crash when adding table columns manually )
  • Index(es):
    • Date
    • Thread