• 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: WeakCache?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: WeakCache?


  • Subject: Re: WeakCache?
  • From: j o a r <email@hidden>
  • Date: Mon, 28 Apr 2003 16:26:20 +0200

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.

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.
Something like this:

@interface CacheController (Removal)

- (void) removeObjectFromCache:(id) obj;

@end

@implementation CacheController (Removal)

- (void) removeObjectFromCache:(id) obj
{
[[self cacheDict] removeObjectForKey: [obj myUniqueProperty]];
}

@end

j o a r

On Monday, Apr 28, 2003, at 15:50 Europe/Stockholm, petite_abeille wrote:

I need to implement something along the line of a weak cache, i.e. a cache which doesn't retain its content. My initial thought was to use a NSDictionary and wrap its values in a NSValue.valueWithNonretainedObject as to not retain them. But... when retrieving an object from the cache... how do I know if it was released or not? Is NSValue.nonretainedObjectValue going to magically returns a nil value if the object was released? How do I know about the whereabout of a nonretainedObjectValue? Any insights welcome :-)
_______________________________________________
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.

  • Follow-Ups:
    • Re: WeakCache?
      • From: petite_abeille <email@hidden>
References: 
 >WeakCache? (From: petite_abeille <email@hidden>)

  • Prev by Date: Re: getting the size of the current window
  • Next by Date: [MEETING] Chicago CAWUG Tuesday, April 29th
  • Previous by thread: WeakCache?
  • Next by thread: Re: WeakCache?
  • Index(es):
    • Date
    • Thread