• 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: ivar access during -finalize
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ivar access during -finalize


  • Subject: Re: ivar access during -finalize
  • From: "email@hidden" <email@hidden>
  • Date: Thu, 08 Mar 2012 20:35:07 +0000

On 8 Mar 2012, at 16:58, Quincey Morris wrote:

>
>> A more robust solution is a probably a separate -dispose method.
>
> Yes, though knowing when to call it can be a puzzle in itself, if there are multiple references to the object. In general, you'll probably need to invent a reference counting mechanism to keep track of when it's OK for your dispose method to actually dispose of things. That sounds ironic in a GC environment, but there's nothing wrong with reference counting when you need to keep count. :)

Thanks for the input Quincey.
This sounds like the approach I should take.

On 8 Mar 2012, at 17:09, Nick Zitzmann wrote:
>
> But if you really must use -finalize to clean up something that's not a manually allocated class or data structure, then at least make sure whatever you're doing is thread-safe, because -finalize is always called on a background thread. +defaultManager is not thread-safe IIRC.
Thanks Nick.
I had toyed with the idea of using a static NSMutableSet instance to stash the ivar NSStrings (which should stop them getting collected along with self) but I had forgotten that finalise doesn't get called on the main thread.

Regards

Jonathan Mitchell
Mugginsoft LLP

_______________________________________________

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: ivar access during -finalize
      • From: "email@hidden" <email@hidden>
References: 
 >ivar access during -finalize (From: "email@hidden" <email@hidden>)
 >Re: ivar access during -finalize (From: Quincey Morris <email@hidden>)

  • Prev by Date: Re: Accessing array in thread safe way
  • Next by Date: Re: NSOpenPanel may not respond to setDirectoryURL?
  • Previous by thread: Re: ivar access during -finalize
  • Next by thread: Re: ivar access during -finalize
  • Index(es):
    • Date
    • Thread