I heard that apple changed some things, concerning the memory management in iOS 5. So where is the best place, to save app data and files in my new iOS 5 application - without losing data?
Asked
Active
Viewed 3,819 times
3 Answers
6
I believe you can save data in either Caches
or Documents
or tmp
directories. The former 2 are actually backed by (i.e. data backup) by iTunes automatically when you connect to it.
For example this code accesses the Caches
directory -
NSArray *cachesDirList = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSString *cacheDir = [cachesDirList objectAtIndex:0];
You can experiment with either Documents
or tmp
in similar fashion. Hope this helps...

Costique
- 23,712
- 4
- 76
- 79

Srikar Appalaraju
- 71,928
- 54
- 216
- 264
-
small typo instead of myPathList I think you mean cachesDirList on line 2. – Tom Belote Mar 14 '12 at 18:13
1
if it's iOS5 only consider using iCloud. For local storage iOS sandbox hasn't changed much, NSDocumentsDirectory (which is backed up to iTunes).

NJones
- 27,139
- 8
- 70
- 88
1
To add to what @Srikar have said, only save data in Caches if you can regenerate it. It has been found that when the device is running short on memory it clears off the app's cache directory. This has been confirmed on various blog post and developers.

Rahul Choudhary
- 3,789
- 2
- 30
- 30