core-data

Passing a ManagedObjectContext to a second view

自古美人都是妖i 提交于 2020-01-11 19:40:06
问题 I'm writing my first iPhone/Cocoa app. It has two table views inside a navigation view. When you touch a row in the first table view, you are taken to the second table view. I would like the second view to display records from the CoreData entities related to the row you touched in the first view. I have the CoreData data showing up fine in the first table view. You can touch a row and go to the second table view. I'm able to pass info from the selected object from the first to the second

Core Data concurrency `performBlockAndWait:` NSManagedObjectContext zombie

╄→гoц情女王★ 提交于 2020-01-11 13:47:13
问题 I have a following crash report from my released app: synchronizeMyWords method fetches the entities from database, creates private queue context with main context parent and finally saves results. All operations are in the background thread. This method being called every time app goes into background and foreground . Here is a simplified method: - (AWSTask *)synchronizeMyWords { __weak typeof(self) weakSelf = self; AWSContinuationBlock block = ^id _Nullable(AWSTask * _Nonnull task) { if (

What is the best way to do a fetch request in CoreData?

自闭症网瘾萝莉.ら 提交于 2020-01-11 13:03:54
问题 I'm trying to find the most efficient way to do a fetch request against CoreData. Previously I have first checked if an error existed, and if it did not I have checked the array of the returned entity. Is there a quicker way to do this. Is something like this an accepted way to do the request? let personsRequest = NSFetchRequest(entityName: "Person") var fetchError : NSError? //Is it okay to do the fetch request like this? What is more efficient? if let personResult = managedObjectContext

Turn off codegen for XCode CoreData model

假装没事ソ 提交于 2020-01-11 11:58:01
问题 Making CoreData model in XCode with already declared classes by myself, compiler code generated duplicates for me. How get rid of that? 回答1: You can disable all automatic code generation by setting the "tools version" for the data model file to Xcode 7.3. This won't have any other effect on the model-- there are no changes to the file format. 回答2: In the Data Model editor, change the Codegen option in the data model inspector on the right to "Manual/none": Sadly, as far as I know, you will

Turn off codegen for XCode CoreData model

别来无恙 提交于 2020-01-11 11:57:26
问题 Making CoreData model in XCode with already declared classes by myself, compiler code generated duplicates for me. How get rid of that? 回答1: You can disable all automatic code generation by setting the "tools version" for the data model file to Xcode 7.3. This won't have any other effect on the model-- there are no changes to the file format. 回答2: In the Data Model editor, change the Codegen option in the data model inspector on the right to "Manual/none": Sadly, as far as I know, you will

Use NSPredicate to add up all values

試著忘記壹切 提交于 2020-01-11 11:49:34
问题 I have a program which uses Core Data. I was kinda cheating when adding the numeric values from each entity in a loop. I read about using NSPredicate to filter the data, but I don't know how to manipulate the data or how the results are even stored. Thanks. 回答1: You can do it in two steps, if that fits your requirements. First filter your data with your NSPredicate and keep it all in an NSArray . Then use a compound operator with Key-Value Coding to get the sum. Below is an example of how it

Use NSPredicate to add up all values

谁说我不能喝 提交于 2020-01-11 11:46:08
问题 I have a program which uses Core Data. I was kinda cheating when adding the numeric values from each entity in a loop. I read about using NSPredicate to filter the data, but I don't know how to manipulate the data or how the results are even stored. Thanks. 回答1: You can do it in two steps, if that fits your requirements. First filter your data with your NSPredicate and keep it all in an NSArray . Then use a compound operator with Key-Value Coding to get the sum. Below is an example of how it

CoreData unique constraints disappears in Xcode

我的梦境 提交于 2020-01-11 11:29:47
问题 What I want to do: Add a unique constraint on the attribute photoID in the entity PhotoUpload . Problem: I tap on constraints and add photoID . When I navigate to a different file and come back to the xcdatamodeld file, the constraint is not present. It is automatically removed. And so the unique constraint is not working. What I have done so far: I have tried deleting the xcdatamodeld file and re-created it, but the same problem persists. Screenshot: Versions: Xcode - 7.3.1 回答1: I believe

Error after adding a new core data model version

限于喜欢 提交于 2020-01-11 10:57:32
问题 I added a new model version, and I set the core data model to use that new version, but I get this error when the application tries to start. "The managed object model version used to open the persistent store is incompatible with the one that was used to create the persistent store." I'm guessing the problem is that the current persistent store is the old version of the model. Is there a way to just delete it so it makes a new one? I don't care about saving any of that data. 回答1: You have to

Error after adding a new core data model version

倖福魔咒の 提交于 2020-01-11 10:57:10
问题 I added a new model version, and I set the core data model to use that new version, but I get this error when the application tries to start. "The managed object model version used to open the persistent store is incompatible with the one that was used to create the persistent store." I'm guessing the problem is that the current persistent store is the old version of the model. Is there a way to just delete it so it makes a new one? I don't care about saving any of that data. 回答1: You have to