Re: [swift-users] UserDefaults with generic keys

2017-07-07 Thread Thierry Passeron via swift-users
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,

Re: [swift-users] UserDefaults with generic keys

2017-07-07 Thread Kim Burgestrand via swift-users
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

Re: [swift-users] UserDefaults with generic keys

2017-07-07 Thread Vladimir.S via swift-users
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

[swift-users] UserDefaults with generic keys

2017-07-07 Thread Thierry Passeron via swift-users
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: