Questions tagged [observableobject]
262 questions
0
votes
0 answers
No ObservableObject of type found. environmentObject may be missing as an ancestor of this view
I'm getting this Fatal Error for the listViewModel. Do I add the @ObservableObject var listViewModel: MakeMyOwnListViewModel to the MakeMyOwnListView.swift or ManifestationMenuApp.swift file?
Thread 1: Fatal error: No ObservableObject of type…

Kraig Kistler
- 35
- 5
0
votes
1 answer
How best to force an observable object to update
My App taps the iPhone inbuilt microphone and uses the frequency detected as a tuner.
The tuner is an observable object which needs to be mocked for testing.
I have set up a protocol to be able to switch between the real tuner (mic tap) and the mock…

Rick
- 21
- 3
0
votes
0 answers
No ObservableObject of type
How do I pass the child view to the ancestor view
ERROR ON ForEach = Thread 1: Fatal error: No ObservableObject of type MenuListFriendshipModel found. A View.environmentObject(_:) for MenuListFriendshipModel may be missing as an ancestor of this…

Kraig Kistler
- 35
- 5
0
votes
1 answer
Has the behavior of asymmetric transitions changed in SwiftUI 4 / iOS 16?
I've been using an asymmetric transition which has been working flawlessly during the time of iOS 15. However, with the introduction of iOS 16 the transition no longer works as expected.
In short: In my app I'm using a paged tabview. When you swipe…

skegget
- 111
- 1
- 7
0
votes
0 answers
Class 'KeyboardViewController' has no initializers
I am trying to use ObservableObject to transfer data from a content view to a view controller. so I create all needed code.
but at the end I got error'Class ViewController has no initializers'
I don't know where I do wrong, actually I had already…

dennis li
- 21
- 4
0
votes
1 answer
Argument passed to call that takes no arguments IOS SwiftUI
I trying to call the login function for user to perform their login action, the way I calling the function is as follow:
struct LogInView: View {
@State private var emailAddress: String = ""
@State private var password: String = ""
…

Hanyi Koh
- 327
- 1
- 4
- 15
0
votes
0 answers
How to show detail of multiple items together which are selected in a list in SwiftUI
Taking the example from SO answer itself where multiple selection in a list is performed. Next step is how to show detail view of selected items together in detail view. Not able to figure out this issue. Created a button which will redirect to…

tintin
- 335
- 2
- 8
0
votes
1 answer
SwiftUI View is not destroyed when window is bring as EnvironObject to the view
I have an app that has no startup window. So in my @main there is no windowGroup.
var body: some Scene {
#if os(macOS)
Settings {
}
#endif
}
But in app somewhere, It is needed to create a window. (Playground runnable)
import…

Chocoford
- 183
- 8
0
votes
2 answers
ForEach in Scrollview does not get updated when @Published gets changed
My ForEach in a Scrollview does not get updated when CommentViewModel comments get updated. It gets successfully updated, but for some reason, CommentView does not get updated. I have tried everything, but can't seem to find a solution.
Maybe…

Alexander Rubino
- 9
- 3
0
votes
1 answer
ObservableObject not updating view in nested loop SWIFTUI
Regarding the following project :
You have an amountSum of 100
When you click on one user "plus" button, this specific user have to pay this amount but if you click on multiple user "plus" button, the amount to pay is divided between them…

mandriao84
- 13
- 4
0
votes
1 answer
Reset `ObservableObject` properties after logout
I have one ObservableObject class for managing login data:
final class LoginData: ObservableObject {
// MARK: - Properties
@Published var otpVerificationType: OTPVerificationType = .mobileNumber
@Published var firstName: String = ""
@Published var…

Mayur Shirsale
- 39
- 1
- 5
0
votes
1 answer
Why does @Published not work in NSManagedObject?
@Published publishes correctly when used in an ObservableObject. But does not seem to publish when used in an NSManagedObject (which conforms to ObservableObject).
In the following example when using Data1 the text below the picker is updated. But…

John
- 964
- 8
- 21
0
votes
1 answer
How to read property from a struct when being in @ObservableObject
I don't know how to read a property that is in a struct from a class that is an Observable Object.
Context:
I'm trying to build an app which consists of 2 views:
a custom calendar;
a popup with a header 'Daily Joke', date formatted as 'MM-dd-yyyy'…

Gleb
- 31
- 7
0
votes
1 answer
Use Swift ObservableObject to change view label when UserSettings change
I’ve created a small sample project in Swift Playgrounds to debug an issue I’ve encountered. This sample project contains the a primary ContentView with a single Text field and a button that opens Settings in a modal view.
When I open Settings and…

Ricky
- 639
- 2
- 6
- 12
0
votes
0 answers
How Do I Make Changes To Child Model Entities Update SwiftUI
I'm trying to implement a UI for a classic parent-children (master-details, etc.) model. All works fine when I have a direct reference to the children in the view, but when I introduce a view-model for the children the UI stops updating when…

Mike Livenspargar
- 31
- 4