title: SwiftUI - How to save custom class data to UserDefaults?
body: <p>I have created a custom class (as an ObservedObject since I need to share this data).
  Everything works but when I force close the app the data resets and I have not found any way to save it to UserDefaults. (Trying to save normally as an object crashed the app).</p>
  <p>How can I save this data? (When pressing the button in SettingsView)</p>
  <p>First time asking here.</p>
  <p>---MainView---</p>
  <pre><code>import SwiftUI
  
  class ProgressData:  ObservableObject {
      @Published var licenseDate: Date = Date()
      @Published var dayProgressValue: Float = 0.00
      @Published var nightProgressValue: Float = 0.00
      @Published var newDriverProgressValue: Float = 0.00
  }
  
  struct MainView: View {
      let defualts = UserDefaults.standard
      @ObservedObject var data = ProgressData()
      
      var body: some View {
         // App Code Here!
      }
  </code></pre>
  <p>--- SettingsView ---</p>
  <pre><code>import SwiftUI
  
  struct SettingsView: View {
      @ObservedObject var data: ProgressData
      
      
      var body: some View {
           Button(action: {
              // What to do in order to save it here?
           })
      }
  </code></pre>
  <p>Thanks.</p>