Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

Problem with set(...) in template #163

Open
chnbr opened this issue Dec 27, 2020 · 0 comments
Open

Problem with set(...) in template #163

chnbr opened this issue Dec 27, 2020 · 0 comments

Comments

@chnbr
Copy link

chnbr commented Dec 27, 2020

Hi,

I am using the set() function in a template like this:

@propertyWrapper
struct UserDefault<T> {
  let key: String
  let defaultValue: T
  
  //let defaults = KeychainWrapper.standard // this gives compiler error "No exact matches in call to instance 'set'"
  let defaults = UserDefaults.standard // this works OK

  init(_ key: String, defaultValue: T) {
    self.key = key
    self.defaultValue = defaultValue
  }
  
  var wrappedValue: T {
    get {
      return defaults.object(forKey: key) as? T ?? defaultValue
    }
    set {
      defaults.set(newValue as T , forKey: key)
    }
  }
}

When using UserDefaults the code compiles, when using KeychainWrapper it does not. Could you please have a look into that issues ?! Thanks and regards

Christian

@chnbr chnbr changed the title Problem with .set in template Problem with set(...) in template Dec 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant