1

I'm using Parse and PFFile and developing iOS app that provide audio contents.

And when I download new mp3 file from cloud, the data look to be saved locally as cache. Caching itself is good.

But my problem is since each audio content is around 3mb and storage usage of my app keep increasing. I want to delete old local cache manually.

It is possible? and how can I delete cached files?

[UPDATED]

Heres my code. Basically I download mp3 data from parse cloud by using getDataInBackgroundWithBlock.

// lessonObj is PFObject
let lessonFile = lessonObj["mp3"] as PFFile
lessonFile.getDataInBackgroundWithBlock {
    (mp3Data: NSData!, error: NSError!) -> Void in
    if ( error == nil ) {
        // next step
    } else {
        // println("error")
    }
}

Thank you!

Ko Ohhashi
  • 844
  • 1
  • 11
  • 23
  • [PFQuery clearAllCachedResults]; This clears all caches. I am not 100% sure if it will clear images too but give it a try. – DBoyer Oct 18 '14 at 18:50
  • I caution clearing the cache frequently though as you will either be performing too many network calls and hit your parse limit, or your app will end up using a ton of network data. – DBoyer Oct 18 '14 at 18:51
  • Did my method work for you? – Dehli May 28 '15 at 20:03
  • To tell the truth, I'm not sure. It seems no as far as I checked the Settings App. "Settings"->"General"->"Usage"->"Manage Storage"->"My App" But only solution looks PFQuery.clearAllCachedResults(). And I have no idea whether Setting App is wrong or the method just set the deleted flag and actually delete files later. – Ko Ohhashi May 29 '15 at 23:42

2 Answers2

0

[PFFile clearAllCachedDataInBackground];

Evtim Georgiev
  • 444
  • 4
  • 10
-1

In order to clear the cache you would need to use the following function.

[PFQuery clearAllCachedResults];
Dehli
  • 5,950
  • 5
  • 29
  • 44