iOS Storage Best Practice

WWDC 2018

Posted by Den on September 30, 2018 · 4 mins read
iOS Storage Best Practice

iOS Storage Best Practice

Tech Talks

iOS Storage Best Practice

Tech Talks

Storage Inventory

Storage Inventory Questions

  • What is this file ?
  • Why is it being stored ?
  • Is it in the correct place ?
  • Should this be backed up ?

iCloud 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

Storage Locations

  • iCloud Drive
  • Documents
  • Application Support
  • Caches
  • Temporary

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

Best Practices

  • Exclude files from backups
    - NSURLIsExcludedFromBackupKey
  • Handle restored data gracefully
    - 64 bit vs 32 bit content
    - Version your content
  • Cloud or Local ?
    - Choose only one
  • NSURL volume capacity details
    - NSURLVolumeAvailableCapacityForImportantUsageKey
    - NSURLVolumeAvailableCapacityForOpportunisticUsageKey