Mit*_*tri 2 iphone backup ios5
我的iPhone应用程序包含大约500 MB的数据.和应用程序将脱机使用此数据.所以我将文件夹标记为不在iTunes上备份/复制.所以我使用的是以下网址:https: //gist.github.com/1999985
但它说'NSURLIsExcludedFromBackupKey'未声明.我也尝试使用https://developer.apple.com/library/ios/#qa/qa1719/_index.html 但我总是返回false ..
那么请让我知道它将如何运作?
谢谢
NSURLIsExcludedFromBackupKey应该在5.1+ SDK上编译好.
由于密钥不适用于5.0,因此以下代码段可用作解决方法.
if (SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(@"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;
}
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"5.1"))
{
NSError *error = nil;
//[URL setResourceValue:[NSNumber numberWithBool:YES] forKey:NSURLIsExcludedFromBackupKey error:&error];
[URL setResourceValue:[NSNumber numberWithBool:YES] forKey:@"NSURLIsExcludedFromBackupKey" error:&error];
return error == nil;
}
Run Code Online (Sandbox Code Playgroud)