Reputation: 68770
My app creates a number of items when first launched and saves them into /Library/Caches/Thumbnails
The app works great.
When I kill the app, then re-run it, those files are not there any more. This does not happen in the simulator.
I have set the no-not-backup attribute, but still when the app runs after being manually shut down, the cache is empty.
Is there a way to have the cache last a bit longer. This is data not created by the user so can't be put into /Documents.
Upvotes: 1
Views: 692
Reputation: 43553
Adding the following code in my FinishedLaunching
method shows a new file at each execution (both on device and on the simulator).
string appdir = NSBundle.MainBundle.BundleUrl.Path;
string cache = Path.GetFullPath (Path.Combine (appdir, "..", "Library", "Caches"));
Console.WriteLine ("Files:");
int i = 0;
foreach (string file in Directory.GetFiles (cache, "*.txt"))
Console.WriteLine ("{0}. {1}", i++, file);
string fname = Path.Combine (cache, i.ToString () + ".txt");
File.WriteAllText (fname, "cache this for later");
So it looks like iOS decided to purge the data to reclaim some space on your device (new feature in iOS 5). This won't happen for every user/devices (if enough space is available) but sadly I do not know how iOS compute this.
Do-not-backup won't help (Caches
is never backed up) unless you save your data inside Documents
but that could cause you other issues as well (wrt AppStore). For a lack of better answer I suggest you the same as the (previous link) blog author, fill a bug report.
Upvotes: 1