russhwolf / multiplatform-settings

A Kotlin Multiplatform library for saving simple key-value data
Apache License 2.0
1.7k stars 67 forks source link

Add API for listing all keys present in a Settings instance #4

Closed russhwolf closed 4 years ago

russhwolf commented 6 years ago

See prototype in the keys branch (#5).

Naively this should be pretty straightforward. Unfortunately, a number of default keys are present on every instance of NSUserDefaults which can't be removed. This seems likely to lead to unexpected per-platform differences in behavior in user code. I would love to get feedback from someone more familiar with the iOS APIs to better understand what the best way to handle this is.

LouisCAD commented 5 years ago

Are the non removable keys in NSUserDefaults well known or detectable in some way so that they could be filtered, without backslash from a potential future iOS (or macOS and other Apple OSes) version that would add or remove keys?

russhwolf commented 4 years ago

This was added in 0.6. For now, no effort is made to handle the default unremovable keys other than noting it in documentation. I'm open to changing that in the future, but since the same thing is already detectable via hasKey(), it didn't seem like a reason to not include this API.