/Documents
Caches
(/Library/Caches
)文件夹里面,但是这个苹果说了,如果在低存储空间的时候会清理的,所以你有可能就这样被清了这些数据,会导致一些列的问题,如果你不在意这些文件是否会被删除,或者这些数据只要保存那么几天,那么这样就行了
如果你要文件不删除但是也备份 可以使用下面代码来做标记 不做备份处理
- (BOOL)addSkipBackupAttributeToItemAtPath:(NSString *)path {NSURL *URL = [NSURL fileURLWithPath:path];
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 5.1) {
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;
} else if ([[[UIDevice currentDevice] systemVersion] floatValue] < 5.1) {
assert([[NSFileManager defaultManager] fileExistsAtPath: [URL path]]);
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;
}
return 0;
}