Save NSCache Contents to Disk

Posted by Cory Imdieke on Stack Overflow See other posts from Stack Overflow or by Cory Imdieke
Published on 2010-12-27T23:47:33Z Indexed on 2010/12/27 23:54 UTC
Read the original article Hit count: 188

Filed under:
|
|

I'm writing an app that needs to keep an in-memory cache of a bunch of objects, but that doesn't get out of hand so I'm planning on using NSCache to store it all. Looks like it will take care of purging and such for me, which is fantastic.

I'd also like to persist the cache between launches, so I need to write the cache data to disk. Is there an easy way to save the NSCache contents to a plist or something? Are there perhaps better ways to accomplish this using something other than NSCache?

This app will be on the iPhone, so I'll need only classes that are available in iOS 4+ and not just OS X.

Thanks!

© Stack Overflow or respective owner

Related posts about iphone

Related posts about cocoa