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 protected]) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [email protected]
