0

There are plenty of answers on how to delete NSDocumentDirectory via code. Unfortunately, that's not what I'm looking for here.

I need a way to delete this from the device. Is there any way short of wiping the entire device and setting it up as a new device?

Deleting the app itself does not delete the NSDocumentDirectory for the application.

1) Will wiping the entire device and setting it up as a new device remove the NSDocumentDirectory?

2) Is there an easier and less costly way than #1 to remove this data off the device, via the device itself?

chris P
  • 6,359
  • 11
  • 40
  • 84
  • 2
    Why do you believe the NSDocumentDirectory is not deleted when you delete the app? – Jessedc Nov 19 '15 at 22:32
  • @Jessedc this SO post http://stackoverflow.com/a/5122894/1652166 mentions that NSDocumentDirectory data persists across updates. So I assumed it was the same when deleting the app. I have some data in NSDocumentDirectory. I delete the app, and when I reinstall the app (iCloud is off btw), the data in that directory is persisting. – chris P Nov 19 '15 at 22:35
  • Persisting across upgrades is different to delete/re-install.That data will not be persisting. If you delete the app the whole sandbox structure is removed. However, the app may be replacing the missing data upon launch after a fresh installation. – Jessedc Nov 19 '15 at 22:46

2 Answers2

1

The NSDocumentsDirectory for an iOS application is stored within it's sandbox environment and will be removed when you delete the app from your device.

In iOS 9 you can see the individual storage of each app by going to Settings -> General -> Storage & iCloud Usage -> Manage Storage There is a shortcut here to delete the app.

Community
  • 1
  • 1
Jessedc
  • 12,320
  • 3
  • 50
  • 63
1

Using iTunes, you can delete files from NSDocumentDirectory of app X on your device if app X has activated UIFileSharingEnabled in the Info.plist.

  1. Select your device on iTunes
  2. Click the Apps tab and select your app X in the 'File Sharing' section.
  3. You can delete files or directories.
Francois Robert
  • 556
  • 10
  • 14