You could put one specific directory inside the documents dir for this purpose, put everything inside and only mark that single directory as do-not-backup using the
addSkipBackupAttributeToItemAtURL
method shown in the article you linked, or use this one that uses a path instead of an URL:
+ (void)addSkipBackupAttributeToPath:(NSString*)path {
u_int8_t b = 1;
setxattr([path fileSystemRepresentation], "com.apple.MobileBackup", &b, 1, 0, 0);
}
example using a directory:
NSString *docsDirPath = [(AppDelegate*)[[UIApplication sharedApplication] delegate] applicationDocumentsDirectory];
NSString *yourContentsDirPath = [docsDirPath stringByAppendingPathComponent:gContentsDirName];
[Utilities addSkipBackupAttributeToPath:yourContentsDirPath];
[EDIT]
I forgot this method use in the delegate to get the documents dir:
- (NSString *)applicationDocumentsDirectory {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *basePath = ([paths count] > 0) ? [paths objectAtIndex:0] : nil;
return basePath;
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…