Open MaxHasADHD opened 8 years ago
@MaxHasADHD I don't understand what you're trying to say — can you elaborate?
NSUserDefaults has a function named registerDefaults
that is faster to use on launch to set initial defaults without checking if it exists and setting it. I would like a way to use Swifty Defaults with this function, currently I have to use the full default key like Defaults.registerDefaults([ DefaultsKeys.AskedToEnableNotificationsKey._key: false])
.
So really, I just want a way so its cleaner and I can just use the short syntax without the DefaultsKeys
and ._key
. To use a DefaultKey
in a dictionary though, it needs to conform to Hashable and Equatable. I have tried to add this myself but I can't get it to be generic, so I can have all bools or all ints registered but not any type.
OK, got it. #59 was proposing an alternative to using registerDefaults
, instead, embedding the default value in the DefaultsKey definition.
The latter definitely seems cleaner, but registerDefaults
has the advantage of working across NSUserDefaults, whether or not you actually use SwiftyUserDefaults and those key values.
Yeah, just ran into this actually. I upgraded from SwiftyUserDefaults 3 to 5 and removed registerDefaults before realizing an internal framework where I'm using the standard API now has no default values. So I'd still love some solution for calling registerDefaults
Hashable and Equatable protocols need to be added so Defaults.registerDefaults([:]) can work