observableobject Questions
3
Solved
I have just updated to XCode 11.4 and some of my code has stopped working. I have some @Published struct variables in an ObservableObject. Previously, when I updated properties on the struct, the d...
Eradis asked 30/3, 2020 at 14:14
3
I have a very basic view that only shows a TextField:
View
struct ContentView: View {
@StateObject var viewModel = ViewModel()
var body: some View {
TextField("Enter a string...", t...
Brusa asked 16/1, 2022 at 21:34
1
Solved
Back in WWDC 2021’s Discover concurrency in SwiftUI, they recommend that you isolate the ObservableObject object to the main actor. E.g.:
struct ContentView: View {
@StateObject var viewModel = Vi...
Dawdle asked 23/7, 2023 at 1:5
3
Solved
I'm new to SwiftUI and I've been experimenting with how to integrate SwiftUI and UIKit together in the same app. I made a simple login screen with SwiftUI.
struct LoginView: View {
var body: som...
Lynd asked 15/2, 2021 at 8:7
2
I have an array of colors assigned that I want saved to UserDefaults. I have a default of gray, green, orange, and red, but I want to allow a color picker to change the green orange and red. The de...
Grossman asked 6/8, 2020 at 21:47
3
Solved
I have a view and a viewModel that should update the ListView when users are added to the user array. I can verify that users are being added, yet the ObservedObject is not updating.
I have a searc...
Ens asked 15/8, 2020 at 15:19
2
Solved
I have a LoginView that shows a RegisterView if the user is not logged in, and a ContentView if he is logged in:
struct LoginView: View {
@EnvironmentObject var userManager: UserManager
var body:...
Eddins asked 1/2, 2020 at 13:59
4
Solved
What is the best approach to have swiftUI still update based on nested observed objects?
The following example shows what I mean with nested observed objects. The balls array of the ball manager is...
Externalism asked 31/3, 2021 at 8:44
2
Solved
I have created an ObservableObject in a View.
@ObservedObject var selectionModel = FilterSelectionModel()
I put a breakpoint inside the FilterSelectionModel's init function and it is called mult...
Khmer asked 30/12, 2019 at 15:48
1
Solved
The app has the following setup:
My main view creates a tag cloud using a SwiftUI ForEach loop.
The ForEach gets its data from the @Published array of an ObservableObject called TagModel. Using a T...
Grannias asked 18/1, 2021 at 14:8
1
Solved
I know, this is one of those "Not working in iOS XX" questions, but I'm completely stuck...
So I have an ObservableObject class that inherits from NSObject, because I need to listen to th...
Noisette asked 30/11, 2020 at 0:47
2
Solved
I'm considered newby in SwiftUI and I have the below ViewModel. But I'm not sure MyViewModel should be singleton. Is that usage is right? And what is the best practice/usage for conforms Observable...
Upanishad asked 18/9, 2020 at 12:18
1
Solved
I have a simple View with a custom month selector. Each time you click chevron left or right,
Inside DateView I had two private vars: startDateOfMonth2: Date and endDateOfMonth2: Date. But they wer...
Rizzi asked 5/7, 2020 at 12:40
1
Solved
I have a state called time
@State var time = 0
and an ObservedObject called timerWrapper
@ObservedObject var timerWrapper = TimerWrapper()
time can be updated from a child view and I want to be a...
Pushup asked 20/6, 2020 at 19:33
1
Background
In my app I have an array of friends that can be added to from another view. I've stored this array of friends in a class which is an ObservableObject. Within my main view, FriendListVie...
Masculine asked 15/6, 2020 at 0:47
2
Solved
I have a problem with observed object in SwiftUI.
I can see changing values of observed object on the View struct.
However in class or function, even if I change text value of TextField(which is ob...
Phthisis asked 21/4, 2020 at 3:35
2
I'd like to extend ObservableObject behavior in SwiftUI to nested classes, and I'm looking for the proper way to do it. It can be done "manually" with Combine, but I imagine there's a much cleaner ...
Inexcusable asked 7/2, 2020 at 18:21
1
I have a UIViewControllerRepresentable struct that is subscribed to an ObservableObject, like this:
struct ViewControllerWrapper: UIViewControllerRepresentable {
@ObservedObject var chartVM = Char...
Kristopher asked 30/10, 2019 at 23:37
1
I have
created a simple ARClass: ObservableObject with @Published var name: String
created a custom ARView: UIView that receives ARClass as a
parameter and draws a Text view displaying ARClass.nam...
Sommelier asked 28/9, 2019 at 2:40
1
© 2022 - 2025 — McMap. All rights reserved.