Wednesday, April 29, 2026
HomeiOS Developmentios - Array of CoreData entity in little one views is not...

ios – Array of CoreData entity in little one views is not refreshed when new information are added or deleted?

[ad_1]

My ContentView accommodates a tab view, which has a number of views. Most of those views require the identical information from an entity in CoreData. Let’s name this entity, Scholar.

Somewhat than fetch college students in every of my views, I assumed it was extra performant so as to add this fetch to my ContentView and go an array of scholar entity into every of my views.

In my views I edit, add and delete scholar information.

I take advantage of…
college.objectWillChange.ship()]
… and …
container.viewContext.save()

Which does replace values which I can see in different views.

Nonetheless, if I add or delete college students in my views, these adjustments aren’t showing in my arrays in different views.

I realise that the fetch must be refreshed in my ContentView.

It appears appropriate to do the fetch as soon as greater up, however clearly this has issues.

What ought to I be doing ?

I am not utilizing any lessons, simply structs.
I assumed @ObserableObject is likely to be required.

Nonetheless, my core knowledge entity does not conform to it…

Generic struct 'ObservedObject' requires that '[Student]' conform to 'ObservableObject'

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments