zoukankan      html  css  js  c++  java
  • ios应用, 设置不自己主动备份到iCloud

    原创文章,转载请注明出处

    ios项目,假设有内置下载或者程序动态生成文件的话,就要注意所下载或生成的文件,要不要自己主动备份到iCloud

    假设没有合适的理由就自己主动上传大文件的话,可能在不能通过应用审核. 收到一下类似这种答复

    We also found that your app does not follow the iOS Data Storage Guidelines, which is required per the App Store Review Guidelines.

    比如有人遇到相同问题 http://stackoverflow.com/questions/16239147/ios-do-not-back-up-attribute

    苹果给出的设置方法:官方文档 https://developer.apple.com/Library/ios/qa/qa1719/_index.html

    应用到项目中, 详细代码例如以下

    #define DownLoad_Directory "Download_Dir"
    
    #pragma mark Download_Dir
    void DeviceClass::initDownloadDir(){
        string l_strDocumentDir = cocos2d::CCFileUtils::sharedFileUtils()->getWritablePath();
        l_strDocumentDir.append(DownLoad_Directory);
        
        NSString* l_strDownloadDir = [NSString stringWithUTF8String:l_strDocumentDir.c_str()];
        NSError* l_error;
        if (![[NSFileManager defaultManager] fileExistsAtPath:l_strDownloadDir]){
            [[NSFileManager defaultManager] createDirectoryAtPath:l_strDownloadDir withIntermediateDirectories:NO attributes:nil error:&l_error]; //Create folder
            
            // exclude downloads from iCloud backup
            NSURL *url = [NSURL fileURLWithPath:l_strDownloadDir];
            if(strcmp(g_systemVersion.c_str(), "5.1") >=0 ){
                if ([url setResourceValue:[NSNumber numberWithBool:YES] forKey:NSURLIsExcludedFromBackupKey error:&l_error] == NO) {
                    NSLog(@"Error: Unable to exclude l_strDownloadDir from backup: %@", l_error);
                }
            }
        }
        
        //this->setDonotBackupInICloud();
    }
    就是在可写文件夹下建立一个新文件夹, 存放下载文件(须要的话,自己主动生成的文件也放到这), 并标记这个文件夹不会被上传到iCloud

    感谢梅俊同事的提醒


    測试方法:

    设置->iCloud->管理储存空间->备份(假设有多设备的话,选择设备)

    应用多的话,点击"显示全部应用" 查到你的应用,在iCloud上备份内容的总容量.

    打开和关闭这个接口, 会发现, 你的应用在iCloud上的备份mwjg容量是不是一样.

  • 相关阅读:
    【转】 java中Class对象详解和类名.class, class.forName(), getClass()区别
    106. Construct Binary Tree from Inorder and Postorder Traversal
    105. Construct Binary Tree from Preorder and Inorder Traversal
    107. Binary Tree Level Order Traversal II
    109. Convert Sorted List to Binary Search Tree
    108. Convert Sorted Array to Binary Search Tree
    110. Balanced Binary Tree
    STL容器迭代器失效问题讨论
    113. Path Sum II
    112. Path Sum
  • 原文地址:https://www.cnblogs.com/lxjshuju/p/6774280.html
Copyright © 2011-2022 走看看