I needed to add a RawRepresentable conformance to Date but it triggered compile errors:
- Ambiguous use of 'getValue'
- Ambiguous use of 'setValue'
Here's a code example:
import Foundation
import ObservableDefaults
@ObservableDefaults
final class UserDefaultsSettings {
var date = Date()
}
extension Date: @retroactive RawRepresentable {
public typealias RawValue = Int
public var rawValue: Int {
return Int(timeIntervalSince1970)
}
public init(rawValue: Int) {
self.init(timeIntervalSince1970: TimeInterval(rawValue))
}
}