iphoneobjective-cnscache

Persisting the contents of NSCache


I am using NSCache to store the webData.

 webData=[[NSData alloc]initWithContentsOfURL:[NSURL URLWithString:urlString]];
[cache setObject:webData forKey:urlString];

The cache will be exist only when my application is running. I want to persist the contents of cache though the application is quit. Writing the contents into the disk is one of the way.Is there any other way ? if not what is efficient way to write the cache into the disk?


Solution

  • Use CoreData as CoreData does is persistency of object graphs with purging and pruning capabilities.

    Refer this for tutorial