• 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上,其他文件目录同理。
  • 相关阅读:
    隐藏TabControl的标签 上海
    最近写的一个存储过程 上海
    DBUS 介绍 上海
    存储过程 几个小例子 上海
    C# BHO 上海
    EXEC和sp_executesql的区别 上海
    office文档转换成mht文档(准备、原理篇) 上海
    Dictionary 排序 上海
    .Net 开源资源 上海
    Geant4.9.5.p01 in ubuntu12.04 OpenGL driver.
  • 原文地址:https://www.cnblogs.com/rankilau/p/4243027.html
Copyright © 2020-2023  润新知