Questions tagged [observedobject]

@ObservedObject is a SwiftUI property wrapper used to mark properties that are not owned by the View, but should update the View. Only ObservableObject conformant types can be annotated with the @ObservedObject property wrapper.

For more info, see the official documentation of @ObservedObject.

173 questions
0
votes
0 answers

Updating core data entity with observedobject

I have created a list of clients which get saved in core data. I added some attributes through an AddView and now I am trying to add a new attribute using a different view. In order to do that I understood I need to use the observedObject property…
0
votes
0 answers

Missing arguments for parameters core data swiftUI

I have created a list of clients which get saved in core data. I added some attributes through an AddView and now I am trying to add a new attribute using a different view. In order to do that I understood I need to use the observedObject property…
0
votes
1 answer

Core Data observed object in SwiftUI

I have created a list of clients which get saved in core data. I added some attributes through an AddView and now I am trying to add a new attribute using a different view. In order to do that I understood I need to use the observedObject property…
0
votes
0 answers

SwiftUI: updating View with changes to Core Data relationship array

I have a SwiftUI view where a Core Data NSManagedObject is passed in (without @FetchRequest) and where the subview needs to show the one-to-many relationship from the first entity. In this case, a Person is passed in, and I want to show the Tags…
Z S
  • 7,039
  • 12
  • 53
  • 105
0
votes
1 answer

SwiftUI @StateObject couldn't refresh view

I can't see the change in the Text object on the ContentView page. However, when I run the same code in .onReceive with print, I can see the change. What's the problem here? I wanted to manage the state of the game from a different place and the…
Ufuk Köşker
  • 1,288
  • 8
  • 29
0
votes
1 answer

Updating observed model during NavigationView animation causes navigation to be aborted

Simple use case: A list of States with a Recents section that shows those States you have navigated to recently. When a link is tapped, the animation begins but is then aborted presumably as a result of the onAppear handler in the detail view…
Rumbles
  • 806
  • 1
  • 8
  • 15
0
votes
0 answers

SwiftUI: state passed to Child View not receiving updates?

I have a MasterView with a List. By clicking on an item, the DetailView is displayed. I am implementing this in the standard SwiftUI way, via the NavigationLink. I am passing the detailState to the DetailView as a parameter. I was expecting that…
0
votes
1 answer

@ObservedObject does not get updated on updating the array

Before I lose my mind over this. May someone please tell me, why it is not working. I am already hours in trying to make this work. ObservedObject just refuses to update my view. struct ContentView: View { @ObservedObject var viewModel =…
S. Braun
  • 143
  • 1
  • 7
0
votes
1 answer

SwiftUI / Firebase: Can I send and receive a single value to Firebase Database using @Published?

I'd like to get the current count to update to my Firebase. I'm making a basic tally counter that I'd like to be able to update in real-time(ish) across devices. Firebase Authentication already configured & linked to the app. class CurrentCount:…
0
votes
1 answer

How to retrieve data from Firestore as soon as SwiftUI view appears?

I have this class CurrentUser that manages the currently logged in user and pulls the data for that user from Firebase. One of CurrentUser's attributes is userEventIDs. I also have a collection of Events documents. Each user has their own array of…
sultan
  • 11
  • 2
0
votes
3 answers

SwiftUI: Why does the changed property of my Data not refresh the UI?

I have the following data model: class MyImage: : Identifiable, Equatable, ObservableObject { let id = UUID() var path: String @Published var coordinate: CLLocationCoordinate2D? } class MyImageCollection : ObservableObject { …
0
votes
1 answer

How can I work on a copy of my CoreData entity which is an @ObservedObject (or do I need to?)?

In my case, I have a ContactProfile view which I want to update. I'd think it would be a good idea to make a copy of the Contact entity, edit the copy and then 'paste' the attributes of the copy back to the original entity and then save it in the…
Rillieux
  • 587
  • 9
  • 23
0
votes
1 answer

How to update ParentView after updating SubView @ObservedObject SwiftUI

This is a simple example for my case. I have a @ObservedObject viewModel (Object1), pass a property (Object2) to another view (View2) . Change value in View 2, and when i go back to View 1, i wish the value is updated too. What is the best…
0
votes
1 answer

Sheet contents won't update depending on parameters

I am calling a sheet when a button is pressed. The button is generated through a ForEach loop and I want to pass the current object into the new sheet. Depending on this object I want the sheet to display different…
benpomeroy9
  • 375
  • 5
  • 21
0
votes
1 answer

How to use Observable Objects with this class?

I'm trying to use Observable Objects with this class:- class malaysiaHolidays: ObservableObject { @Published var holidayName : String @Published var holidayDate : String init(holidayName: String, holidayDate:…