sindresorhus / Defaults

💾 Swifty and modern UserDefaults
https://swiftpackageindex.com/sindresorhus/Defaults/documentation/defaults
MIT License
1.93k stars 115 forks source link

Support external storage option? #150

Open sindresorhus opened 9 months ago

sindresorhus commented 9 months ago

Sometimes you need to store something that is a bit larger, like a icon image. Storing this in UserDefaults would be slow as it has to be decoded each time it's accessed.

SwiftData has a .externalStorage option that makes it store it to a file on disk instead of in the database. Maybe we could do something similar.

static let icon = Key<NSImage?>("icon", externalStorage: true)

This can only be supported if the suite option is not given as otherwise we don't know where to store it.