Skip to content

Instantly share code, notes, and snippets.

@ra9r
Created October 9, 2022 09:47
Show Gist options
  • Save ra9r/0b148e70bf2937ee1f91e772fb5a1c3f to your computer and use it in GitHub Desktop.
Save ra9r/0b148e70bf2937ee1f91e772fb5a1c3f to your computer and use it in GitHub Desktop.
How to initialize a @StateObject inside an init()
struct PumpChangeCardView: View {
@StateObject var model: PumpChangeCardViewModel
init(_ record: PumpChangeRecord) {
self._model = StateObject(wrappedValue: PumpChangeCardViewModel(record))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment