【发布时间】:2015-05-20 12:02:48
【问题描述】:
我使用标准方法从备份中排除:
+ (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL
{
assert([[NSFileManager defaultManager] fileExistsAtPath:[URL path]]);
NSError *error = nil;
BOOL success = [URL setResourceValue:@(YES)
forKey:NSURLIsExcludedFromBackupKey error:&error];
if (!success) {
NSLog(@"Error excluding %@ from backup %@", [URL lastPathComponent], error);
}
return success;
}
正如一些人建议的那样,我将此方法与 [NSURL fileURLWithPath:path] 一起使用,但它不起作用:
从备份中排除 groups.xml 时出错 Error Domain=NSCocoaErrorDomain Code=513 "Не удалось завершить операцию. (Cocoa, ошибка 513)"
用户信息=0x170272ac0 {
NSURL=file:///private/var/mobile/Containers/Bundle/Application/59286088-C226-4653-A84F-A4B5D40C11DE/anatomyfree.app/groups.xml, NSFilePath=/private/var/ mobile/Containers/Bundle/Application/59286088-C226-4653-A84F-A4B5D40C11DE/anatomyfree.app/groups.xml, NSUnderlyingError=0x1702492a0 "Не удалось завершить операцию. 不允许操作" }
此文件存在。它已被解析,但不能从备份中排除。这是什么原因?
我使用 iOS 8.2、iPhone 6、ru 语言环境。
这里是方法调用:
NSString *path = [[NSBundle mainBundle] pathForResource:fileName ofType:extension];
NSURL *url = [NSURL fileURLWithPath:path];
[Utilities addSkipBackupAttributeToItemAtURL:url];
【问题讨论】:
标签: ios objective-c icloud