nmdias / DefaultsKit

Simple, Strongly Typed UserDefaults for iOS, macOS and tvOS
MIT License
1.43k stars 95 forks source link

Support Implicit Member Expression #13

Closed KyoheiG3 closed 6 years ago

KyoheiG3 commented 6 years ago

Hi @nmdias

Can Key class inherit a class like following, for example?

public class AnyKey {}

public final class Key<ValueType: Codable>: AnyKey {}

This makes it possible to do following.

extension AnyKey {
    static let key = Key<String>("someKey")
}

defaults.set("Codable FTW 😃", for: .key)

My goal is like #9.

Thanks.

nmdias commented 6 years ago

Thank you for the suggestion @KyoheiG3, it worked out really well 😃