【问题标题】:How to stop the Document backup to icloud in before ios 5.0如何在 ios 5.0 之前停止将文档备份到 icloud
【发布时间】:2013-11-03 04:19:30
【问题描述】:

我正在做一个应用程序。我正在运行时在 DocumentDirectory 中创建 .txt 文件。但是它们将备份到 icloud。所以现在我想在 ios 5 版本之前停止备份。从 ios 5 开始我们有停止备份过程的选项。我想将文件存储在文档中,而不是在 5.0 之前的版本中备份。

【问题讨论】:

    标签: ios iphone icloud nsdocumentdirectory


    【解决方案1】:

    如果您在 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;
    }
    

    【讨论】:

    • 根据苹果指南将所有元数据放入 Library/Cache/.. 因为它不会备份到 iCloud。不要将您的数据放入 Document 文件夹中。获取 ios 版本,如果是 ios5 系列则放置不备份标志,如果更高则保留它。但请确保将数据放入 Library/Cache/..
    猜你喜欢
    • 2012-10-09
    • 1970-01-01
    • 2013-04-17
    • 1970-01-01
    • 2022-07-15
    • 1970-01-01
    • 2016-05-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多