core-data

iOS 13.4 CoreData SwiftUI app crashes with “EXC_BREAKPOINT (code=1, subcode=0x1f3751f08)” on device

南笙酒味 提交于 2020-04-14 04:46:25
问题 A very simple CoreData app: All code provided below. Start up with CoreData template single view app. 2 entities with a string attribute each: Message(title) and Post(name) A NavigationView containing NavigationLink to a list of messages NavigationLink to a list of posts Each linked ListView (Message/Post) has a button to add an item to the list a button to remove all items from the list Now, when you run this app on a simulator (any iOS 13.x version) all runs as expected from the description

Use Swift's Date with CoreData

心已入冬 提交于 2020-04-08 09:16:26
问题 I have a lot of date fields in my database model. CoreData allows to use NSDate or TimeInterval to save dates depending on "Use Scalar Type" option. However both these options are bad for me since I want to use dates as Date objects. Since NSDate is not implicitly convertible to Date I have to cast/convert values to Date or to implement a lot of custom setters/getters in my NSManagedObject classes. I have tried to use ValueTransformer but it does not work with non-@objc classes like Date . So

Use Swift's Date with CoreData

↘锁芯ラ 提交于 2020-04-08 09:15:33
问题 I have a lot of date fields in my database model. CoreData allows to use NSDate or TimeInterval to save dates depending on "Use Scalar Type" option. However both these options are bad for me since I want to use dates as Date objects. Since NSDate is not implicitly convertible to Date I have to cast/convert values to Date or to implement a lot of custom setters/getters in my NSManagedObject classes. I have tried to use ValueTransformer but it does not work with non-@objc classes like Date . So

How to use hardcoded file path names with sandbox

瘦欲@ 提交于 2020-04-05 06:26:35
问题 Ok, yes I know now that you can not use hardcoded paths with sandbox. Up to this point I have not delt with sandbox, so I never encountered it. I have a Coredata App (Mac OSx) and I used the default save code and the default path location (user/...../applicationsupport/... This, of coarse, is not acceptable in the sandbox. Without requiring the user to manually open the data file each time the program is launched, is there another way to deal with this? I would appreciate any input

CoreData and SwiftUI: Context in environment is not connected to a persistent store coordinator

霸气de小男生 提交于 2020-04-04 19:11:38
问题 I am trying to teach myself Core Data by building a homework managing app. My code builds fine and the app runs okay until I try to add a new assignment to the list. I get this error Thread 1: EXC_BREAKPOINT (code=1, subcode=0x1c25719e8) on the following line: ForEach(courses, id: \.self) { course in . The console also has this error: Context in environment is not connected to a persistent store coordinator: <NSManagedObjectContext: 0x2823cb3a0> . I know very little about Core Data and am at

CoreData and SwiftUI: Context in environment is not connected to a persistent store coordinator

狂风中的少年 提交于 2020-04-04 19:11:31
问题 I am trying to teach myself Core Data by building a homework managing app. My code builds fine and the app runs okay until I try to add a new assignment to the list. I get this error Thread 1: EXC_BREAKPOINT (code=1, subcode=0x1c25719e8) on the following line: ForEach(courses, id: \.self) { course in . The console also has this error: Context in environment is not connected to a persistent store coordinator: <NSManagedObjectContext: 0x2823cb3a0> . I know very little about Core Data and am at

how to populate picker from ViewModel object, setting to initial state of first element and handle actions on selection of picker item

我怕爱的太早我们不能终老 提交于 2020-03-25 19:00:13
问题 I have a view class showing list of items coming from ViewModel class, in picker. Initial state of this picker is first element from the array of objects of the viewModel class. On selection of item from picker, I want to do different actions in that view - 1. send the object info to different screen on button click. 2. display information with respected to selected object from picker. import SwiftUI import Combine struct SetConfiguration: View { @ObservedObject var profileListVM :

SwiftUI List View not updating after Core Data entity updated in another View

有些话、适合烂在心里 提交于 2020-03-25 12:31:53
问题 I have a Lesson entity stored in Core Data one of whose variables is to store whether the lesson is complete. The lessons are listed in a SwiftUI list and when selected go to the View where the game exists. Once the game is completed, the complete variable is updated to true. And what is supposed to happen is that the list View displays the listed game with a check mark beside the game. However, what is happening is that when I save the 'completed' state of the lesson in the game (in the

SwiftUI List View not updating after Core Data entity updated in another View

不问归期 提交于 2020-03-25 12:31:11
问题 I have a Lesson entity stored in Core Data one of whose variables is to store whether the lesson is complete. The lessons are listed in a SwiftUI list and when selected go to the View where the game exists. Once the game is completed, the complete variable is updated to true. And what is supposed to happen is that the list View displays the listed game with a check mark beside the game. However, what is happening is that when I save the 'completed' state of the lesson in the game (in the

Xcode 11 doesn't recognize Core data Entity

自作多情 提交于 2020-03-21 06:12:18
问题 I just declared an entity called "Users" array: var UsersArray = [Users]() I got this error: use of unresolved identifiers "Users" hint : I did import CoreData and created the entity 回答1: Please try this solutions !! Solution 1 :- Product->Buld for testing solved this issue for me(it solves most unresolved identifier bugs for some strange reason) Solution 2 :- changing import Foundation to import UIKit. It seems like UIApplication isn't included in Foundation framework. Solution 3 :-