美文网首页
WWDC IOS Storage Best Practice

WWDC IOS Storage Best Practice

作者: Jerrydu96 | 来源:发表于2019-07-18 00:52 被阅读0次

    Storage Locations

    iCould Drive

    Accessible across all devices
    Cached locally
    Automatically uploaded to iCloud
    Requires file coordination

    Documents Directory

    User-visible content
    Accessible in Files app
    Support "Open in Place"
    Support "File Sharing Enabled"
    Storage Settings management

    Application Support Directory

    Required files
    Can be hierarchical
    Persistent
    Included in iCloud and iTunes Backups
    Reported in "Documents & Data"

    Caches Directory

    Purgeable or transient content
    Good for downloadable storage
    Not included in backups
    Reclaimed by OS if needed

    Temporary Directory

    Transient files
    Remove when done
    Not included in backups

    Storing Your App’s Data Efficiently

    To ensure that backups are as efficient as possible, store your app’s data according to the following guidelines:
    Only documents and other data that is user-generated, or that cannot otherwise be recreated by your application, should be stored in the <Application_Home>/Documents directory and will be automatically backed up by iCloud.
    Data that can be downloaded again or regenerated should be stored in the <Application_Home>/Library/Caches directory. Examples of files you should put in the Caches directory include database cache files and downloadable content, such as that used by magazine, newspaper, and map applications.
    Data that is used only temporarily should be stored in the <Application_Home>/tmp directory. Although these files are not backed up to iCloud, remember to delete those files when you are done with them so that they do not continue to consume space on the user’s device.
    Use the "do not back up" attribute for specifying files that should remain on device, even in low storage situations. Use this attribute with data that can be recreated but needs to persist even in low storage situations for proper functioning of your app or because customers expect it to be available during offline use. This attribute works on marked files regardless of what directory they are in, including the Documents directory. These files will not be purged and will not be included in the user's iCloud or iTunes backup. Because these files do use on-device storage space, your app is responsible for monitoring and purging these files periodically.
    

    iOS Data Storage Guidelines -> https://developer.apple.com/icloud/documentation/data-storage/index.html

    相关文章

      网友评论

          本文标题:WWDC IOS Storage Best Practice

          本文链接:https://www.haomeiwen.com/subject/ilwhlctx.html