Category "core-data"

SwiftUI List not updating when core data property is updated in other view

@State var documents: [ScanDocument] = [] func loadDocuments() { guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else {

Core data - TableView - Toggle - Index out of range

I have a data model like this. The data is connected to core data. import Foundation import CoreData @objc(Aktie) class Aktie: NSManagedObject { @NSManaged

Sync for the first time the CloudKit data

My app backup the data to iCloud or sync with user device through the user iCloud account using NSPersistentCloudKitContainer privateDataBase. The main problem

How to use sharing with CoreData/CloudKit synching

I have an app that works well synchronizing the local core data records with a private database. I would like to make the CloudKit database a shared database an

onAppear is causing problem with the preview but no error is shown

self learning beginner here. When I remove .onAppear{add()}, the preview works fine. I tried to attach it to other the body view, the Vstack but it causes anot

CoreData not updated until application inactivates

I'm building a Macos CoreData+CloudKit app. I first create my container by doing this: let container = NSPersistentCloudKitContainer(name: "TestApp") let descri

Failed to find a unique match for an NSEntityDescription CoreData Swiftui

When I use my app, sometimes, I have an error that appear, it seems to be randomly (or I didn't figure out when exactly...), then all my lists are empty (like i

SwiftUI 2.0 CoreData issues with new project - 'Cannot find type 'Item' in scope'

[EDIT] I was hoping that Apple would have fixed what is obviously a bug. The solution is to clear the cache, close and reopen Xcode.. I am on Xcode Beta and sta

Can’t pass data correctly to modal presentation using ForEach and CoreData in SwiftUI

Im trying to pass data of some object from list of objects to modal sheet, fetching data from CoreData. The problem is that no matter what object I click on i

Passing Data Forward In Swift Without Segue

I'm currently making a to do list app using Swift 4. The home view controller has a tableview with some categories in it and when one is selected, it takes the

SwiftUI: List does not update automatically after deleting all Core Data Entity entries

I know SwiftUI uses state-driven rendering. So I was assuming, when I delete Core Data Entity entries, that my List with Core Data elements gets refreshed immed

How to limit the number of results in a FetchRequest in SwiftUI

How can I limit the size of the retrieved FetchedResults when making a FetchRequest to CoreData? struct ContentView: View { var fetchRequest:FetchRequest&l

SwiftUI DatePicker Binding optional Date, valid nil

I'm experimenting code from https://alanquatermain.me/programming/swiftui/2019-11-15-CoreData-and-bindings/ my goal is to have DatePicker bind to Binding<

ViewContext not receiving updates from newBackgroundContext()

There is a similar question in stack overflow already but it doesn't work for me. There is a use case in my application where I have to observe the database ch

How to change toggle on just one Core Data item using ForEach in SwiftUI?

How to change just one toggle in a list without subviews? I know how to make it work if I extract Subview from everything inside ForEach, but how to do it on on

Swift 5.5 Concurrency: how to serialize async Tasks to replace an OperationQueue with maxConcurrentOperationCount = 1?

I’m currently migrating my app to use the concurrency model in Swift. I want to serialize Tasks to make sure they are executed one after the other (no par

CoreData valueForKey issue on Xcode 13

I have an issue in a client's app where calls to valueForKey: on an NSManagedObject subclass are failing for particular CoreData properties when the app is buil

Crash when deleting an item from List in SwiftUI with custom RandomAccessCollection

Basic approach I am currently tring to clean up my Core Data/SwiftUI code, and part of that is moving code out of my Views and into my ViewModels. Since it seem

How to sum the numbers(Int16) of stored core data - Swift 3

I have stored the letters(String), numbers(Int16) and Date(Date) in the core data. And the filter(NSPredicate) succeeded in organizing only the necessary data.

How to set a custom store URL for NSPersistentContainer

How can I set a custom store.sqlite URL to NSPersistentContainer? I have found an ugly way, subclassing NSPersistentContainer: final public class PersistentCo