Re: WeakCache?
Re: WeakCache?
- Subject: Re: WeakCache?
- From: j o a r <email@hidden>
- Date: Mon, 28 Apr 2003 17:55:43 +0200
On Monday, Apr 28, 2003, at 16:56 Europe/Stockholm, petite_abeille
wrote:
No, it will not magically do anything to the NSValue you keep. The
value object is just an integer (or something similar) and does not
have any real connection to the live object it points to.
Anyway to check for the validity of what nonretainedObjectValue is
returning?
Not that I know of - and at least nothing that is easy or straight
forward.
My suggestion is that you add a method to remove the object from the
cache when it is being removed from the collection, either to the
dealloc method of the object itself, or to the remove method in the
controller.
I see... but if I need to proactively remove an object from a cache in
dealloc, this creates a very unfortunate dependency between the object
and its cache... something I would like to avoid altogether :/ Any
idea about how to implement a generic weak cache mechanism which
doesn't depends on any help from the objects it's holding to stay
valid?
I still think you can find a design where it's perfectly OK to let the
cache know that an object is about to be removed, be it via
notifications, direct methods or by the controller / owner of the
object in question. Think outside of the box!
j o a r
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.