Le 16 déc. 08 à 05:56, Andy Lee a écrit :
On Dec 15, 2008, at 6:27 PM, John Michael Zorko wrote:
I'm not concerned about the contents per se -- i'm concerned about
releasing something I declared as static, just to create it again
later.
Creating and re-creating objects is in itself nothing to be afraid
of. It happens all the time.
The main relevant difference between the two approaches -- (1) empty
the existing dictionary, or (2) release the existing dictionary and
make a new dictionary -- is that in the latter case, it's
conceivable that some object or thread might be caching a stale
reference to the old dictionary. This might or might not be a real
concern in your specific app.
Catching a stale reference or accessing a dictionary in a non thead
safe way. I don't know what is the worst.
I wonder if you are concerned not because 'lookup' is static (which
has a specific meaning), but because the variable is globally
visible and is referred to all over the place, and therefore
possibly at greater risk for the stale-reference problem? But if
that's your concern, then you've answered your own question: just go
with [lookup removeAllObjects].
--Andy
Part of me is saying "just release the dictionary's contents, not
the dictionary itself".
Regards,
John
_______________________________________________
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to arch...@mail-archive.com