VJVJ
VJVJ

Reputation: 443

How to clear the data of iOS app on iPhone/iPad

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.

Upvotes: 1

Views: 1601

Answers (1)

Sumit Oberoi
Sumit Oberoi

Reputation: 3475

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)
}

Upvotes: 1

Related Questions