core-data

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

爷,独闯天下 提交于 2020-02-18 05:51:36
问题 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

Core Data subquery with Multiple Relationship

白昼怎懂夜的黑 提交于 2020-02-16 04:01:58
问题 This is the structure of my core DB tables. Wanted to create a subquery in a predicate, Below is the description of the query. Generate all unique Submission, where SubmisisonField.value matches with an array. This query for image on top. For Second image which is having Employee table request is: Generate all ActivityFeedCard, where Employee name matches to string. Now id field in Employee is the same field which is SubmissionField.value or we can say SubmissionField.value == Employee.id. We

Core Data - using Transient Properties in Group By

…衆ロ難τιáo~ 提交于 2020-02-14 06:41:11
问题 I'm creating a UITableView with some aggregated data. Along the way, Section Headings need to be used in sorting and grouping the table view cells. The issue is I would like to use a Transient Property within the NSFetchRequest to generate section headings & results sorts. The issue is that whilst setting up the NSFetchRequest I receive a ''NSInvalidArgumentException', reason: 'Invalid keypath player.fullName passed to setPropertiesToFetch'. The main entity for the NSFetchRequest is a Player

Why might releasing a managed object crash in -[_PFManagedObjectReferenceQueue _queueForDealloc:]?

南楼画角 提交于 2020-02-13 02:11:11
问题 I am occasionally seeing crashes with a stack trace like this: 0 libobjc.A.dylib 0x97dc0edb objc_msgSend + 27 1 com.apple.CoreData 0x97edcdc2 -[_PFManagedObjectReferenceQueue _queueForDealloc:] + 162 2 com.apple.CoreData 0x97edccbe -[NSManagedObject release] + 94 3 com.apple.CoreFoundation 0x9318ef38 CFRelease + 152 4 com.apple.CoreFoundation 0x931a7460 __CFBasicHashStandardCallback + 384 5 com.apple.CoreFoundation 0x931a706e __CFBasicHashDrain + 478 6 com.apple.CoreFoundation 0x9318f101

NSSortDescriptor with to-many relationship

风格不统一 提交于 2020-02-10 11:39:06
问题 I have a Parent entity which has to-many Child. If I order the Parent fetch with a property (e.g. name), everything works fine. But if I try this: NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"child.@count" ascending:NO]; It doesn't work. I've also tried to add [fetchRequest setRelationshipKeyPathsForPrefetching:[NSArray arrayWithObject:[entityProperties objectForKey:@"child"]]]; But it didn't work as well. Am I allowed to sort by to-many.@count or do I need to

How to convert stored values to JSON format using Swift?

久未见 提交于 2020-02-08 10:08:30
问题 I am trying to convert stored coredata values to JSON format and the JSON format value need to assign a single variable, because this generated JSON I need to send to server. Below code I tried to get coredata stored values but don’t know how to generate JSON required format. Getting values from coredata let context = (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext let fetchRequest = NSFetchRequest<NSFetchRequestResult>(entityName: "User") do { let results =

How to convert stored values to JSON format using Swift?

独自空忆成欢 提交于 2020-02-08 10:07:50
问题 I am trying to convert stored coredata values to JSON format and the JSON format value need to assign a single variable, because this generated JSON I need to send to server. Below code I tried to get coredata stored values but don’t know how to generate JSON required format. Getting values from coredata let context = (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext let fetchRequest = NSFetchRequest<NSFetchRequestResult>(entityName: "User") do { let results =

Core Data entities missing when tested on device

不羁的心 提交于 2020-02-07 19:52:52
问题 I am trying to make a simple app using Xcode/swift. I am able to save and retrieve data in core data when using the simulator, however when I tested the app using an actual iPhone device my existing data are missing. i don't know why this is, and what to do about it. I am new in iOS development, thanks in advance. 回答1: This is expected behavior, because youк needed data stored in simulator memory on the mac, and you should copy that database file from simulator to Supporting Files in main

Encryption with Core Data in background

有些话、适合烂在心里 提交于 2020-02-07 03:42:25
问题 This question is different from questions here, because of the app being mostly in the background. It is a requirement for our application that we keep the data store encrypted. Our current implementation is using SQLite using SQLCipher. The plan is to move to Core Data. I'm looking for a solution to keep the data encrypted, while still accessible in the background and is not restricting in terms of queries-NSPredicates and migration (schema change). Below are all the options I've been

How to use the generated classes after Xcode did “Class Definition” for Core Data?

久未见 提交于 2020-02-06 07:56:29
问题 I'm using Xcode 11.3.1 and I choose Class Definition for example Entity in a new project. I can't seem to reference the generated class. Even after I press build let x = Project() Use of unresolved identifier 'Project' 回答1: Can't reproduce. I created a new vanilla Single View app with Core Data direct from the template and made one Entity just like yours: Then I added one line of code to the view controller's viewDidLoad ; it compiles just fine: class ViewController: UIViewController {