【发布时间】:2013-11-03 04:19:30
【问题描述】:
我正在做一个应用程序。我正在运行时在 DocumentDirectory 中创建 .txt 文件。但是它们将备份到 icloud。所以现在我想在 ios 5 版本之前停止备份。从 ios 5 开始我们有停止备份过程的选项。我想将文件存储在文档中,而不是在 5.0 之前的版本中备份。
【问题讨论】:
标签: ios iphone icloud nsdocumentdirectory
我正在做一个应用程序。我正在运行时在 DocumentDirectory 中创建 .txt 文件。但是它们将备份到 icloud。所以现在我想在 ios 5 版本之前停止备份。从 ios 5 开始我们有停止备份过程的选项。我想将文件存储在文档中,而不是在 5.0 之前的版本中备份。
【问题讨论】:
标签: ios iphone icloud nsdocumentdirectory
如果您在 ios5 之前安装了 ios 版本,则不会有数据备份到云端。因为i-cloud自带ios5。
在 ios5.0 中,您可以使用以下功能停止备份
(BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL {
NSLog(@"in add skipBackUpAtrribute method.......");
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;
}
【讨论】: