I, like many developers, got an email from Apple recently that stated we should move our data from the documents directory into another folder to permit more streamlined bac
Library/Caches
is probably a good answer for many apps. Especially when the app will work fine is cached data is lost and clearing the cache does not also destroy all record of what data a user might have elected to cache and where it can be re-obtained from.
For apps which have data which does not belong in Caches
consider Library/Application Support
.
http://developer.apple.com/library/ios/documentation/FileManagement/Conceptual/FileSystemProgrammingGUide/FileSystemOverview/FileSystemOverview.html#//apple_ref/doc/uid/TP40010672-CH2-SW1
Application Support:
Use this directory to store all application data files except those associated with the user’s documents. For example, you might use this directory to store application-created data files, configuration files, templates, or other fixed or modifiable resources that are managed by the application. An application might use this directory to store a modifiable copy of resources contained initially in the application’s bundle. A game might use this directory to store new levels purchased by the user and downloaded from a server.
All content in this directory should be placed in a custom subdirectory whose name is that of your application’s bundle identifier or your company.
In iOS, the contents of this directory are backed up by iTunes.
Unfortunately the Application Support directory is still backed up and falls under Apple's new data storage guidelines. Depending on how sensitive reviewers choose to be about total backed up file size this may still lead to rejections.
iOS 5.0.1 introduced a flag to address this issue:
https://developer.apple.com/library/ios/#qa/qa1719/_index.html
Their recommendation is to create a folder in /Library/ like /Library/PrivateDocs , and put your files there. However you will also have to set a "do not backup" flag on them as every file in /Library except for those in /Library/Cache or tmp are backed up by default. Set the flag on PrivateDocs folder with this command:
#include <sys/xattr.h>
- (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL
{
const char* filePath = [[URL path] fileSystemRepresentation];
const char* attrName = "com.apple.MobileBackup";
u_int8_t attrValue = 1;
int result = setxattr(filePath, attrName, &attrValue, sizeof(attrValue), 0, 0);
return result == 0;
}