在icloud上禁用文档文件夹及其所有子文件夹的备份? [英] Disable backup of documents folder and all its sub folders on icloud?

查看:118
本文介绍了在icloud上禁用文档文件夹及其所有子文件夹的备份?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个已经运行的企业应用程序,它在文档文件夹中存储了大量文档。我希望禁用Documents文件夹中所有这些文档和文件夹的iCloud备份。
问题是文件夹内的内容不断动态变化,为每个文件添加
kCFURLIsExcludedFromBackupKey 的想法听起来有点困难,因为那里我的代码中有多个类可以写入文档目录。

I have an already running enterprise application which stores a lot of documents inside the documents folders. I wish to disable the iCloud backup of all these documents and folders inside the Documents folder. The problem is that the contents inside the folder keep on changing dynamically and the idea of adding kCFURLIsExcludedFromBackupKey for every files sounds a bit difficult, as there are multiple classes in my code which can write to the documents directory.

有没有办法可以禁用整个文档文件夹及其子文件夹的上传。

Is there any way I can disable the upload of the entire documents folder and its subfolder.

推荐答案

在您的应用程序的appDelegate中,使用以下方法

In appDelegate of your application in the following method

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

添加此代码

    NSArray *urlArray = [[NSFileManager defaultManager] URLsForDirectory: NSDocumentDirectory inDomains: NSUserDomainMask];
    NSURL *documentsUrl = [urlArray firstObject];

    NSError *error = nil;
    BOOL success = [documentsUrl setResourceValue: [NSNumber numberWithBool: YES]
                                  forKey: NSURLIsExcludedFromBackupKey error: &error];
    if(!success){
        NSLog(@"Error in disabling %@ from backup %@", [documentsUrl lastPathComponent], error);
    }

这篇关于在icloud上禁用文档文件夹及其所有子文件夹的备份?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆