sindresorhus / Defaults

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

Is there a way to get an iterator over all the keys? #127

Closed davidwernhart closed 1 year ago

davidwernhart commented 1 year ago

I would love to computationally access all the keys via an iterator or array-like access. This would be very handy for saving backups of the defaults and modifying or migrating keys without always explicitly accessing them via Defaults[.name].

Thank you for your help and kind regards, David

sindresorhus commented 1 year ago

There's no way to do this or even add it. Swift needs better reflection capabilities first.

However, you can access all the UserDefaults values using UserDefaults.standard.dictionaryRepresentation().

davidwernhart commented 1 year ago

I see, that's really unfortunate.

Thank you anyways.