Reputation: 999
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?
Upvotes: 2
Views: 3837
Reputation: 73698
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...
Upvotes: 6
Reputation: 3809
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.
Upvotes: 1
Reputation: 27147
if it's iOS5 only consider using iCloud. For local storage iOS sandbox hasn't changed much, NSDocumentsDirectory (which is backed up to iTunes).
Upvotes: 1