I am new in iOS development. My app was rejected because it must follow the iOS Data Storage Guidelines. I have already read some answer here on Stack Overflow, and I have already read some blogs.
I am using this following method in my appdelegate.m for stop icloud back up. My database size is 79mb.
- (BOOL)addSkipBackupAttributeToItemAtPath:(NSString *)path {
NSURL *url = [NSURL fileURLWithPath: path];
assert([[NSFileManager defaultManager] fileExistsAtPath:[url path]]);
NSError *error = nil;
BOOL success = [url setResourceValue: [NSNumber numberWithBool: YES] forKey: NSURLIsExcludedFromBackupKey error: &error];
if(!success){
NSLog(@"Error excluding %@ from backup %@",[url lastPathComponent],error);
}
return success;
}
I have also used this code:
NSArray *pathsa = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
NSString *basePath = ([pathsa count] > 0) ? [pathsa objectAtIndex:0] : nil;
NSArray *documents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:basePath error:nil];
NSURL *URL;
NSString *completeFilePath;
for (NSString *file in documents) {
completeFilePath = [NSString stringWithFormat:@"%@/%@", basePath, file];
URL = [NSURL fileURLWithPath:completeFilePath];
NSLog(@"File %@ is excluded from backup %@", file, [URL resourceValuesForKeys:[NSArray arrayWithObject:NSURLIsExcludedFromBackupKey] error:nil]);
}
But still its showing 109 MB in iCloud Storage.