views:

85

answers:

1

The NSUserDefaults class provides us a convenient way to store/restore shared data. But I got a question: how to delete data when user uninstalls the app? As we all know, apps should clean all its data/files when it's deleted. Leaving anything that won't be used anymore shouldn't happen, isn't it? As far as I know, an app will never know when it's uninstalled. How to remove the shared data in userdefaults then?

A: 

The iPhone automatically deletes all of an app's data when it deletes the app. That's all. No need to clean up.

Jacob Relkin
Thats what I thought too but I've noticed when uninstalling and re-installing an app that all my old NSUserDefaults data is still there.
mbehan
Are you seeing this in the Simulator? The Simulator doesn't always clear things out properly (it's a bug). To ensure you've got a clean Simulator environment, go to "Reset Contents and Settings…" in the "iPhone Simulator" menu.
Nick Forge