• 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: How to use the NSCache
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to use the NSCache


  • Subject: Re: How to use the NSCache
  • From: Nick Zitzmann <email@hidden>
  • Date: Mon, 16 May 2011 00:35:33 -0600

On May 15, 2011, at 11:50 PM, Leon Qiao wrote:

> Have you ever used the NSCache?

Yes.

> I'm a little confused on how to use it. I
> want to make a list to hold some images in memory.
> And the memory overload is a big problem. So I wish I could use the NSCache
> to
> manage the memory.

NSCache is similar to NSMutableDictionary, with the differences being:
1. It is guaranteed to be thread-safe.
2. It is much slower to access.
3. It may throw out objects from time to time. You can set costs and limits, but they're not guaranteed to be followed.
4. It is not toll-free bridged to anything in CoreFoundation.
5. You can't query the number of objects that are in the cache.
6. You can't enumerate a cache.

I can only recommend using NSCache to store objects you wouldn't care about if they were arbitrarily destroyed. If the objects must not be destroyed, or if access speed is an issue, then use NSMutableDictionary instead.

Nick Zitzmann
<http://www.chronosnet.com/>



_______________________________________________

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

References: 
 >How to use the NSCache (From: Leon Qiao <email@hidden>)

  • Prev by Date: How to use the NSCache
  • Next by Date: Re: Delegate & Notification
  • Previous by thread: How to use the NSCache
  • Next by thread: Core Animation animations stop prematurely at random
  • Index(es):
    • Date
    • Thread