Search code examples
ioscachingparse-platformpffile

How to delete PFFile's cache


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!


Solution

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

    [PFQuery clearAllCachedResults];