Nice!
The key is to have a non generic base class as storage for statics and a
subclass for generic types… brilliant.
I am definitely going to try this one.
Vladimir’s solution is also a nice fact to know. The key point of the compile
error message seems to be « static __stored__ « hence,
Here's yet another alternative. I read an article doing this very thing a
while back, it might be interesting to you:
http://radex.io/swift/nsuserdefaults/static/. It makes the key type a class
instead, and inherits from a non-generic parent class to which it adds the
static properties.
The gist
On 07.07.2017 14:02, Thierry Passeron via swift-users wrote:
Hi Everyone,
Using Swift 3.1, I was wondering if I could come up with something largely
inspired by Notification.Name to help me deal with UserDefaults so I started by
doing something like:
The only kind of solution I was able to
Hi Everyone,
Using Swift 3.1, I was wondering if I could come up with something largely
inspired by Notification.Name to help me deal with UserDefaults so I started by
doing something like:
public struct DefaultsKey: RawRepresentable, Equatable, Hashable, Comparable {
public var rawValue: