core-data

How to group core data items by date in SwiftUI?

笑着哭i 提交于 2020-04-18 05:41:36
问题 What I have in my iOS app is: TO DO ITEMS To do item 3 24/03/2020 ------------ To do item 2 24/03/2020 ------------ To do item 1 23/03/2020 ------------ What I would like to have is: TO DO ITEMS 24/03 To do item 3 24/03/2020 ------------ To do item 2 24/03/2020 ------------ 23/03 To do item 1 23/03/2020 ------------ =============== What I have so far: I am using Core Data and have 1 Entity: Todo . Module: Current Product Module. Codegen: Class Definition. This entity has 2 attributes: title

SwiftUI app crashes every time when trying to add item to grouped items

天大地大妈咪最大 提交于 2020-04-18 03:46:32
问题 My app crashes and I am getting a following error when I try to sort items by date in a ForEach loop: 2020-03-24 16:55:13.830146+0700 list-dates[60035:2135088] *** Assertion failure in -[_UITableViewUpdateSupport _setupAnimationsForNewlyInsertedCells], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKitCore_Sim/UIKit-3901.4.2/UITableViewSupport.m:1311 (lldb) on line: class AppDelegate: UIResponder, UIApplicationDelegate { of AppDelegate.swift At first my app loads in simulator, but after I

How to use hardcoded file path names with sandbox

微笑、不失礼 提交于 2020-04-17 22:51:26
问题 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

NSFetchedResultsControllerDelegate not triggered when adding first item to DB.Triggered only when I added a second item

孤街浪徒 提交于 2020-04-17 22:07:27
问题 My application has two tab bars. The first one presents a list of games added on view controller and save them on the core data database. Switching on the second tab/view reads from the database and presents it inside a table view. I implemented the NSFetchedResultsControllerDelegate with a fetch method. When I add the first item to the context on the first tab and switch to second tab, FRC delegate methods (controllerWillChangeContent(_:), controller(_:didChange:at:for:newIndexPath:),

NSFetchedResultsControllerDelegate not triggered when adding first item to DB.Triggered only when I added a second item

一曲冷凌霜 提交于 2020-04-17 22:06:21
问题 My application has two tab bars. The first one presents a list of games added on view controller and save them on the core data database. Switching on the second tab/view reads from the database and presents it inside a table view. I implemented the NSFetchedResultsControllerDelegate with a fetch method. When I add the first item to the context on the first tab and switch to second tab, FRC delegate methods (controllerWillChangeContent(_:), controller(_:didChange:at:for:newIndexPath:),

getting Black Screen while integrating CoreData to my ToDo app Swift

二次信任 提交于 2020-04-16 06:08:20
问题 I am learning Swift from Online Course and while my instructor integrating CoreData to her existing code, She creates a new core data model and copy-paste App Delegate. But in her DataModel, there is not a SceneDelegate while there is in mine. The problem is that I can not do the same things as her because of these differences. Therefore, I copied SceneDelegate.swift file into my Xcode project and copy other things from DataModel App Delegate. After this solution, I got a black screen. I do

getting Black Screen while integrating CoreData to my ToDo app Swift

你说的曾经没有我的故事 提交于 2020-04-16 06:08:01
问题 I am learning Swift from Online Course and while my instructor integrating CoreData to her existing code, She creates a new core data model and copy-paste App Delegate. But in her DataModel, there is not a SceneDelegate while there is in mine. The problem is that I can not do the same things as her because of these differences. Therefore, I copied SceneDelegate.swift file into my Xcode project and copy other things from DataModel App Delegate. After this solution, I got a black screen. I do

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

*爱你&永不变心* 提交于 2020-04-16 05:48:15
问题 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 in the list, only the data form last added object appears in the details view. The same goes for deleting the object - no matter what object I'm trying to delete, the last one is deleted all the time. Problem disappears using NavigationLink, but it is not suitable for me. Here is my code: import SwiftUI struct CarScrollView: View {

SwiftUI use relationship predicate with struct parameter in FetchRequest

梦想与她 提交于 2020-04-16 04:01:25
问题 How do I do use @FetchRequest with a parameter passed to a struct ? struct TodoItemView: View { var todoList: TodoList @FetchRequest( entity: TodoItem.entity(), sortDescriptors: [NSSortDescriptor(key: "order", ascending: true)], predicate: NSPredicate(format: "todoList == %@", todoList) ) var todoItems: FetchedResults<TodoItem> ... I have todoList set up as a One relationship of TodoItem via TodoList . It is giving me the error: Cannot use instance member 'todoList' within property

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

杀马特。学长 韩版系。学妹 提交于 2020-04-14 04:46:28
问题 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