Skip to content

Commit

Permalink
Create RefdsDefault.swift
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelesantos committed Jul 17, 2024
1 parent 28c312e commit 61cdd02
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Sources/RefdsShared/Data/RefdsDefault.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import Foundation

@propertyWrapper
public struct RefdsDefault<Value> {
let key: String
let defaultValue: Value
var defaults: UserDefaults = .standard

public var wrappedValue: Value? {
get { defaults.object(forKey: key) as? Value }
set { defaults.set(newValue, forKey: key) }
}
}

0 comments on commit 61cdd02

Please sign in to comment.