zoukankan      html  css  js  c++  java
  • app上架,iCloud存储的内容过多问题。

    问题描述:我的db 图片 MP3 文件 当用户启动app的时候都把它们拷贝到/Documents 目录下 这样貌似不行。
    In particular, we found that on launch and/or content download, your app stores 2.02 MB. To check how much data your app is storing:

    - Install and launch your app
    - Go to Settings > iCloud > Storage & Backup > Manage Storage 
    - If necessary, tap "Show all apps" 
    - Check your app's storage
    上边英文主要是说,除用户自己创建的文件,其他文件如app的自己离线文件,都不能存到icloud上,这是苹果的存储规则。
    问题解决:
    1、最好不要把app自己生成的文件和用户的文件放在一个文件目录下,方便以后获取路径。
    2、如何防止文件被备份到iCloud 和iTunes
    从iOS 5.1开始,应用可以使用NSURLIsExcludedFromBackupKey 或 kCFURLIsExcludedFromBackupKey 文件属性来防止文件被备份。这些API是通过通过旧的,弃用的方式的直接设置额外属性。所有运行在iOS5.1的都应该使用这些API包防止文件被备份。
    在iOS5 .1上防止文件被备份

    - (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL

    {

    assert([[NSFileManager defaultManager] fileExistsAtPath: [URL path]]);

    NSError *error = nil;

    BOOL success = [URL setResourceValue: [NSNumber numberWithBool: YES]

    forKey: NSURLIsExcludedFromBackupKey error: &error];

    if(!success){

    NSLog(@"Error excluding %@ from backup %@", [URL lastPathComponent], error);

    }

    return success;

    }

    addSkipBackupAttributeToItemAtURL 方法怎么用呢?
    然后更改为此在 app delegate.m 中:
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory , NSUserDomainMask, YES);
    documentsDir = [paths objectAtIndex:0];
    [self addSkipBackupAttributeToItemAtURL:[NSURL fileURLWithPath:documentsDir];
    这样就可以保证app的documents文件内容不备份到icloud上,其他文件目录同理。
  • 相关阅读:
    SpringBoot打包的程序部署到服务器后一直在后台运行
    ubuntu搭建mysql数据库
    解决ubuntu16.04 ‘E: 无法获得锁 /var/lib/dpkg/lock-frontend
    项目部署篇之——下载安装Xftp6,Xshell6
    linux 文件 chgrp、chown、chmod
    linux 正确的关机方法
    linux 常用命令
    spring 事务
    Spring 中 ApplicationContext 和 BeanFactory 的区别
    java 异常处理
  • 原文地址:https://www.cnblogs.com/rankilau/p/4243027.html
Copyright © 2011-2022 走看看