|
@StateObject private var viewModel = ContentViewModel() |
If SettingsView is not the root owner of ContentViewModel, this will create a new instance every time the view is recreated.
That means:
- devices reload unexpectedly
- selected device resets
- inconsistent state across app
FIX:
@EnvironmentObject var viewModel: ContentViewModel
TrackWeight/TrackWeight/SettingsView.swift
Line 10 in e322cae
If SettingsView is not the root owner of ContentViewModel, this will create a new instance every time the view is recreated.
That means:
FIX:
@EnvironmentObject var viewModel: ContentViewModel