core-data

Deleting CoreData Item which is also an @ObservedObject in DetailView causing App Crash in Swift 5

本小妞迷上赌 提交于 2020-12-15 05:26:16
问题 i am currently working with SwiftUI and CoreData . Situation: I have a User Detail View with a Delete Button at the Bottom. When pressed, the Core Data Entry of the User is getting deleted and the App Navigation goes back to the Root Navigation View, which is a List of all Users. Problem: Every Time the Delete Button is clicked the App crashes with the following Error Message : *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[User timeCreated]:

Core Data Derived Attributes with a sum function

回眸只為那壹抹淺笑 提交于 2020-12-14 23:53:44
问题 I have two entities in my app: User & Expense . A user has many expenses. Expense as an attribute amount (of type Int32). I added a derived attribute expensesCount (of type Int16) on the user to count the number of expenses, using the derivation expenses.@count . It's working fine, the app compiles, launches, and when I save a relationship, the value for the expensesCount attribute is updated. I also added a derived attribute expensesAmount on the user to count the total amount of all related

Core Data Derived Attributes with a sum function

余生颓废 提交于 2020-12-14 23:52:16
问题 I have two entities in my app: User & Expense . A user has many expenses. Expense as an attribute amount (of type Int32). I added a derived attribute expensesCount (of type Int16) on the user to count the number of expenses, using the derivation expenses.@count . It's working fine, the app compiles, launches, and when I save a relationship, the value for the expensesCount attribute is updated. I also added a derived attribute expensesAmount on the user to count the total amount of all related

Core Data Derived Attributes with a sum function

ⅰ亾dé卋堺 提交于 2020-12-14 23:46:43
问题 I have two entities in my app: User & Expense . A user has many expenses. Expense as an attribute amount (of type Int32). I added a derived attribute expensesCount (of type Int16) on the user to count the number of expenses, using the derivation expenses.@count . It's working fine, the app compiles, launches, and when I save a relationship, the value for the expensesCount attribute is updated. I also added a derived attribute expensesAmount on the user to count the total amount of all related

Core Data Derived Attributes with a sum function

时间秒杀一切 提交于 2020-12-14 23:44:32
问题 I have two entities in my app: User & Expense . A user has many expenses. Expense as an attribute amount (of type Int32). I added a derived attribute expensesCount (of type Int16) on the user to count the number of expenses, using the derivation expenses.@count . It's working fine, the app compiles, launches, and when I save a relationship, the value for the expensesCount attribute is updated. I also added a derived attribute expensesAmount on the user to count the total amount of all related

Core data fetchRequest gives executeFetchRequest:error: <null> is not a valid NSFetchRequest

久未见 提交于 2020-12-10 08:57:07
问题 I while ago, I updated one of my apps to iOS 10, and I got it working, and since then I've been using it on my phone (installed without removing old app, where new app replaced old one). Now when I've removed the app from my iPhone, and reinstalled the same one it doesn't work. I've been trying out to solve this problem by different changes and trying to get an understanding on what is going wrong. I also searched on Google and here on Stack Overflow without any success. The error I get is

SwiftUI - how to update data with fetchRequest in init

断了今生、忘了曾经 提交于 2020-12-08 02:17:30
问题 I am doing a CoreData fetch inside my init() method of the View. I am not using FetchRequest in SwiftUI, as I need a predicate based on a parameter which is send to the View aswell. Using that parameter in the @FetchRequest will cause an error, as the variable has not been initialized. I am doing following fetch Request inside the init() //FetchRequest let fetch : NSFetchRequest<Article> self.articleRows = [Article]() fetch = Article.fetchRequest() as! NSFetchRequest<Article> fetch.predicate

This NSPersistentStoreCoordinator has no persistent stores (device locked). It cannot perform a save operation. specialized static method

拈花ヽ惹草 提交于 2020-12-06 12:28:45
问题 App crashes randomly on production when trying to save or update a record. It's a VOIP app, getting background CallKit pushes and on some conditions, writes them so CoreDate DB. I suspect that that's what's crashing the app but I could not find any reference to it online. Tried reproducing this issue locally with no luck, could be because it's impossible to debug with Xcode before you unlock your phone for the first time. This is my CoreDate code from AppDelegate: lazy var persistentContainer

How to fill TextField with data from Core Data and update changes?

江枫思渺然 提交于 2020-12-01 12:00:45
问题 I am trying to learn how to Save, Edit and Delete data using Core Data. So far, with the help of this great community, I have managed to Save and Delete, but I don't know how to Edit and Update currently saved data. Here is a simple example of an app I am working on. It is a list with items from Core Data. I am adding new list entries on a modal (AddItemView) and deleting them on EditItemView. I would like to edit and update data as well on the AddItemView view. I managed to pass data to hint

How to automatically reflect CoreData+iCloud Changes in SwiftUI view?

荒凉一梦 提交于 2020-12-01 11:19:26
问题 🤓 So ...I have an app with StoreData and iCloud enabled. My data is syncing between the devices but I don't ge the behaviour I want when it comes to reflecting the changes in the UI. The behaviour I want: When a user has my app open on two devices (A & B) and makes a change one one (A) of them I want the change to automatically reflect in the second (B) device UI within some reasonable time. The behaviour I currently have: When the user makes changes on one device (A) nothing ever happens on