Move regions storage from UserDefaults to disk. Storing regions in a database could be overkill since there are only a handful of infrequently-updated regions.
Currently, regions are stored as encoded objects in UserDefaults. We should use Codable to store OBA-regions in /Library/Application Support and custom regions in /Documents.
Files stored in /Documents in the app's sandbox are synced via iCloud and may be exposed via Files.app, which could be helpful for sharing custom regions.
The currently selected region would continue to be stored in UserDefaults, identified by its RegionIdentifier.
Possible file structure
Library/
└ Application Support/ ☜ Won't be deleted by clearing cache, but won't be synced via iTunes/iCloud
└ Regions/
└ default-regions.json ☜ This can be refreshed via OBA (not user-generated data)
Documents/
└ custom-regions/ ☜ Any .json in the directory that can be decoded into a Region object.
└ region-a.json
└ region-b.json
Library/Application Support/Regions/default-regions.json is not a copy of regions.json, it's the encoded-JSON of how OBAKitCore.Region.
This change should not require an Internet migration, so we don't need to inform the user.
Move regions storage from UserDefaults to disk. Storing regions in a database could be overkill since there are only a handful of infrequently-updated regions.
Currently, regions are stored as encoded objects in UserDefaults. We should use
Codable
to store OBA-regions in/Library/Application Support
and custom regions in/Documents
.Files stored in
/Documents
in the app's sandbox are synced via iCloud and may be exposed via Files.app, which could be helpful for sharing custom regions.The currently selected region would continue to be stored in UserDefaults, identified by its
RegionIdentifier
.Possible file structure
Library/Application Support/Regions/default-regions.json
is not a copy of regions.json, it's the encoded-JSON of howOBAKitCore.Region
.This change should not require an Internet migration, so we don't need to inform the user.