2

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?

V-Xtreme
  • 6,775
  • 6
  • 33
  • 76
  • See my answers [here](http://stackoverflow.com/a/43026958/746347) and [here](http://stackoverflow.com/a/43026939/746347). – mixel Apr 27 '17 at 10:15
  • Possible duplicate of [Save NSCache Contents to Disk](http://stackoverflow.com/questions/4542707/save-nscache-contents-to-disk) – mixel Apr 27 '17 at 10:16

2 Answers2

1

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

Refer this for tutorial

Paresh Navadiya
  • 37,381
  • 10
  • 77
  • 128
  • I am not used coreData yet . so i am not comfortable in it. also Can i add core data in my existing application. – V-Xtreme Jun 29 '12 at 04:58
  • ok i will. But how can add core data in existing application? – V-Xtreme Jun 29 '12 at 05:12
  • [this](https://developer.apple.com/library/ios/#documentation/DataManagement/Conceptual/iPhoneCoreData01/Introduction/Introduction.html#//apple_ref/doc/uid/TP40008305-CH1-SW1) link [this](http://stackoverflow.com/questions/2032818/adding-core-data-to-existing-iphone-project) link [this](http://stackoverflow.com/questions/3908836/iphone-add-core-data-to-existing-project) link – Paresh Navadiya Jun 29 '12 at 05:21
0

You can choose TMCache as it has ability of persistence.

mixel
  • 22,724
  • 10
  • 111
  • 154
Mrug
  • 4,594
  • 2
  • 28
  • 51