The correct place to cache data so it's available until the user chooses to remove it

KeithBoyntonKeithBoynton GBMember ✭✭

I've been trying to get my iOS app to cache data to a place where the user cannot access it directly but it stays cached until the user chooses to clear it.

The ideal solution would be to a place where it appears in Settings > iPhone Storage > AppName > Recommendations although I already provide a mechanism to clear it from within the app so that is not necessarily required.

At the moment I'm caching the data to:

Environment.SpecialFolder.Personal

Which resolves to:

/Users/XXX/Library/Developer/CoreSimulator/Devices/C4B608A1-2BD0-4DBA-834F-888A133F773C/data/Containers/Data/Application/E72B834A-1260-43E6-8370-E3C92F1FF7D2/Documents/

However, what I'm seeing is that the XXX part of the Data/Application/XXX/Documents path changes on each execution. Firstly, I'm not sure whether that's related to the simulator specifically or whether it's the same behaviour for an installed app on a device. I'm seeing that the cached data disappears (intermittently) between executions of the app on a device so I suspect it's the same.

What is the recommended way to cache data so

1) it's not directly accessible to the users
2) it appears in the Settings > iPhone Storage > AppName > Recommendations section
3) it stays cached until the user specifically choose to clear it (either from the app or the Recommendations section)

Answers

Sign In or Register to comment.