Post

Replies

Boosts

Views

Activity

Reply to @AppStorage with Date in SwiftUI
I used a setter and a getter. I got the idea from Nick Roosevelt on this post on forums.swift.org. (Thanks Nick!) I realise it's not an extension on Date, but it's quick & simple and easy to understand, and it's working well for me. @AppStorage("storedStartTime") var storedStartTime = Date.now.timeIntervalSinceReferenceDate var startTime: Date { set {storedStartTime = newValue.timeIntervalSinceReferenceDate} get {return Date(timeIntervalSinceReferenceDate: storedStartTime)} }
Apr ’24