In my app i have to store Core Data Database and audio files, so i decoded to put them in Documents directory. To prevent them from backing up, when i first launch the app, i put the Don't BackUp flag like this
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[self addSkipBackupAttributeToItemAtURL:[self applicationDocumentsDirectory]];
}
- (NSURL *)applicationDocumentsDirectory
{
return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
}
- (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL
{
if (&NSURLIsExcludedFromBackupKey == nil) { // iOS <= 5.0.1
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;
} else { // iOS >= 5.1
return [URL setResourceValue:[NSNumber numberWithBool:YES] forKey:NSURLIsExcludedFromBackupKey error:nil];
}
}
But it seems like it doesn't work - i still get rejected:
We found that your app does not follow the iOS Data Storage Guidelines, which is required per the App Store Review Guidelines.
In particular, we found that on launch and/or content download, your app stores 3.6 MB. To check how much data your app is storing:
- Install and launch your app
- Go to Settings > iCloud > Storage & Backup > Manage Storage
- If necessary, tap "Show all apps"
- Check your app's storage
And the other problem is that i just can't check that - i don't see my app in
Settings > iCloud > Storage & Backup > Manage Storage
Maybe the problem is only with 5.0 that i kind of not think about here?
The problem is with iOS 5.0, in this iOS you should not put the dont backup flag The dont back up flag was introduced in ios 5.0.1 We did face similar problem with our app, it has been rejected several times So we had to do a work around to handle different iOSes We needed to support iOS < 5.0, iOS 5.0, and iOS > 5.0
So after contacting apple, we didnt find any solution except to have different paths on different iOSes
We had a function like this:
We used and still use this function.
Please read more
http://developer.apple.com/library/ios/#qa/qa1719/_index.html