core-data

Migration can be done without multiple data model versions. Hurrah?

喜欢而已 提交于 2020-03-03 09:07:16
问题 I was referring a wonderful tutorial Swift Core Data Tutorial for migrations in core data. The tut stated that migrations in core data go hand in hand with multiple versions of data model. I was experimenting on light-weight migrations and got to figure out the following points: Scenario - I had a data model and I tried to add a some new attributes to an entity and I got an error as - iOS Version - 9.1 Swift Version - 2.2 "The model used to open the store is incompatible with the one used to

How to avoid Core Data warning “Entity should have an inverse relationship”?

 ̄綄美尐妖づ 提交于 2020-03-01 02:03:33
问题 I have a model graph, where there is several entities that have one to many relationship with other entity. It means that inverse relationship should be one to many, but that is impossible. The core data works well without inverse relationship, The only thing that drives me crazy is warnings) Do somebody know how to avoid these specific warnings? Thanks. 回答1: Inverse Relationships Most relationships are inherently bi-directional. If a Department has a to-many relationship to the Employees

How to “touch” a Core Data entity, to trigger NSFetchedResultsController?

旧街凉风 提交于 2020-02-29 05:41:04
问题 Say you have a core data entity, public class CDPerson: NSManagedObject You get new info from the net ... a field changes, p.name = 'Debbie' That CDPerson item is "touched" and hence, your NSFetchedResultsController will trigger , perfect. But say CDPerson can belong to CDAddress In core data, a change in CDAddress does not trigger a change in CDPerson But. When an address is touched, you DO want to touch the relevant person items, so that results controllers will know CDPerson has been

Core Data: error: Exception was caught during Core Data change processing

╄→гoц情女王★ 提交于 2020-02-26 05:13:33
问题 I have been having this problem now for a few days and it's really frustrating.. I have been reviewing my code over and over again tried different thing and keeps having the same issue.. Which happens only 50% of the times not always. This makes it harder.. The Problem, I am parsing the data from 3 csv files to my Core Data, which 2 of the files parsing always goes well but the middle/second file is where the crash always happens so, this will be address to that file and managedObjectContext

Core Data: error: Exception was caught during Core Data change processing

坚强是说给别人听的谎言 提交于 2020-02-26 05:12:12
问题 I have been having this problem now for a few days and it's really frustrating.. I have been reviewing my code over and over again tried different thing and keeps having the same issue.. Which happens only 50% of the times not always. This makes it harder.. The Problem, I am parsing the data from 3 csv files to my Core Data, which 2 of the files parsing always goes well but the middle/second file is where the crash always happens so, this will be address to that file and managedObjectContext

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

落花浮王杯 提交于 2020-02-25 06:30:30
问题 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 immediately. I use this code, which gets my Entity cleaned succesfully: func deleteAll() { let fetchRequest: NSFetchRequest<NSFetchRequestResult> = ToDoItem.fetchRequest() let deleteRequest = NSBatchDeleteRequest(fetchRequest: fetchRequest) let persistentContainer = (UIApplication.shared.delegate as! AppDelegate).persistentContainer do {

Core Data Entity Unique Constraint Does Not Work

≡放荡痞女 提交于 2020-02-22 05:45:18
问题 I am trying to set a constraint in core data with the new Entity Constraints inspector (To make the name of the item unique). All that I've read says it's pretty simple - Set the constraint and handle the error. I don't get any errors and can add the same entry as many times as I want. The app does require IOS 9.0, Xcode tools requirement is set to 7.0 The constraint, category1Name, is a String. My addItem code is: func addNewRecord() { //check to be sure the entry is not empty if

Array of Objects in Core Data Entity?

帅比萌擦擦* 提交于 2020-02-20 04:57:20
问题 I've got two entities, one named exercise and the other named workout. I would like to store several different exercises in each workout object. What is the correct logic here? Create an array of exercises in each workout? 回答1: You can't create arrays in Core Data. You can simulate them, however, using To-Many Relationships. Add a relationship to your Workout entity called, say, exercises . Then set its Destination to the Exercise entity and check the "To-Many Relationship" checkbox. Note

Array of Objects in Core Data Entity?

寵の児 提交于 2020-02-20 04:57:08
问题 I've got two entities, one named exercise and the other named workout. I would like to store several different exercises in each workout object. What is the correct logic here? Create an array of exercises in each workout? 回答1: You can't create arrays in Core Data. You can simulate them, however, using To-Many Relationships. Add a relationship to your Workout entity called, say, exercises . Then set its Destination to the Exercise entity and check the "To-Many Relationship" checkbox. Note

SwiftUI Bug - List changes lock UI - (OLD TITLE: SwiftUI CoreData fetch is very slow)

ぐ巨炮叔叔 提交于 2020-02-18 05:52:11
问题 Update #4 I've Reordered this post to read a little more easily. What you will read below will detail a bug I've experienced using SwiftUI. I recently requested code level support from apple who confirmed same and asked that I reach out to feedback for resolution (which was also done, no answer yet). The bug is this : After displaying a List or ForEach in a SwiftUI View, if you alter that view by changing the number of items listed, the UI locks up while it attempts to calculate the number of