You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One very useful feature when debugging is to use Arguments Passed On Launch to override user defaults. It seems DefaultsKit is not able to handle these keys because of the way it attempts to cast to Key.ValueType.
However, if we pass -wipeDatabaseOnLaunch true argument on launch, the underlying type returned by user defaults is no longer Optional<Bool> but instead Optional<Any>. Since the implementation of get tries to cast to the key's ValueType this cast will fail and you get nil instead.
One very useful feature when debugging is to use Arguments Passed On Launch to override user defaults. It seems DefaultsKit is not able to handle these keys because of the way it attempts to cast to
Key.ValueType
.For example, let's say I have the following:
This works in the normal case:
However, if we pass
-wipeDatabaseOnLaunch true
argument on launch, the underlying type returned by user defaults is no longerOptional<Bool>
but insteadOptional<Any>
. Since the implementation ofget
tries to cast to the key'sValueType
this cast will fail and you getnil
instead.As a workaround I had to implement a specialized version of
get
which usesbool(forKey:)
Unfortunately, this needs to be done for each of the types you could use as launch arguments. Haven't found a cleaner solution to this.
The text was updated successfully, but these errors were encountered: