1

Is it possible to clear the data of an app on iPhone/iPad without deleting the app? In Settings, general->usage->app where I can delete the app.

Thanks in advance.

Okku
  • 7,468
  • 4
  • 30
  • 43
VJVJ
  • 435
  • 3
  • 21
  • Whatever data app downloads it goes to document directory only, so you can delete whichever data you want to delete from there. Here is the reference: http://stackoverflow.com/questions/4749269/how-to-delete-the-contents-of-the-documents-directory-and-not-the-documents-dir – Mrunal Jul 15 '15 at 11:36

1 Answers1

1

So these are the steps for clearing data

1) clear core Data model Delete/Reset all entries in Core Data?

2) Set all NSUserDefaults to their default value

3) Delete all files in document directory

let fileManager = NSFileManager.defaultManager()
let enumerator = fileManager.enumeratorAtURL(cacheURL, includingPropertiesForKeys: nil, options: nil, errorHandler: nil)
while let file = enumerator?.nextObject() as? String {
    fileManager.removeItemAtURL(cacheURL.URLByAppendingPathComponent(file), error: nil)
}
Community
  • 1
  • 1
Sumit Oberoi
  • 3,455
  • 2
  • 18
  • 18