core-data

Fetch aggregate data from NSManagedObject using another expression as argument to sum: expression

怎甘沉沦 提交于 2020-01-10 03:15:28
问题 Is it possible to use expression as argument for sum: expression? I have entity ( NSManagedObject class) Drink with properties costPerDrink , numberOfDrinks and drinkingDate . I would like to get sum of total costs ( numberOfDrinks multiplied by costPerDrink ) within time period. While I have no problems getting sum on single property (e.g. sum of numberOfDrinks within time period), when I try to use sum expression on another (multiply) expression I got error: NSInvalidArgumentException,

iOS 9, 10 CoreData: Failed to load optimized model at path

我们两清 提交于 2020-01-10 02:05:39
问题 I have created new version of CoreData model and migrated existing one to it. Application works without any issues on iOS 9+, but for iOS 9 and 10 I am getting this error: 2017-10-22 19:28:37.081 CafeManager[16654:1918728] CoreData: Failed to load optimized model at path '/Users/dj-glock/Library/Developer/CoreSimulator/Devices/A81AA9C4-7B59-4422-BA0A-0FD0D1A05205/data/Containers/Bundle/Application/DD66571C-4EB6-4A8B-A99B-B447DD0FFFBA/CafeManager.app/CafeManager.momd/CafeManager v2.omo' iOS 10

How to use predicates with fetchRequest in Core Data

非 Y 不嫁゛ 提交于 2020-01-10 01:28:11
问题 I pass a contact Identifier from Contacts tableview controller to another Location tableview controller. So I define a delegate ContactSelectionDelegate and implement method userSelectedContact in Location tableview controller and get contactIdentifierString I am searching the database to find a match for contactIdentifierString and find value for another attribute provider name. This involves searching the whole database. Is there a faster way by assigning a predicate to the context

How to use predicates with fetchRequest in Core Data

青春壹個敷衍的年華 提交于 2020-01-10 01:28:06
问题 I pass a contact Identifier from Contacts tableview controller to another Location tableview controller. So I define a delegate ContactSelectionDelegate and implement method userSelectedContact in Location tableview controller and get contactIdentifierString I am searching the database to find a match for contactIdentifierString and find value for another attribute provider name. This involves searching the whole database. Is there a faster way by assigning a predicate to the context

Core data: any way to fetch multiple entities?

懵懂的女人 提交于 2020-01-09 12:56:07
问题 I'm just getting started with Core Data, and as a learning exercise I'm building an app where I need to display different types of objects in a single table view. As an example, say I have an entity for "Cheese" and an unrelated entity for "Pirate". On the main screen of my app, the user should be able to create either a "Cheese" or a "Pirate" instance to add to the table view. So, using the core data editor I've created entities for Cheese and Pirate... however, an NSFetchRequest seems to

Core data: any way to fetch multiple entities?

对着背影说爱祢 提交于 2020-01-09 12:52:10
问题 I'm just getting started with Core Data, and as a learning exercise I'm building an app where I need to display different types of objects in a single table view. As an example, say I have an entity for "Cheese" and an unrelated entity for "Pirate". On the main screen of my app, the user should be able to create either a "Cheese" or a "Pirate" instance to add to the table view. So, using the core data editor I've created entities for Cheese and Pirate... however, an NSFetchRequest seems to

Core Data - lightweight migrations and multiple core data model files (xcdatamodel)

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-09 12:36:02
问题 I'm having a problem performing a lightweight migration when migrating from a store that is defined by two separate xcdatamodel files. In version 1.0 of my app, I had the models broken out into an analytics model, model-A, and everything else in model-B. When compiling, the models would be grouped together and everything proceeded smoothly. When working on the new version, 1.1, I upgraded model-B by adding a new model version to model-B and setting that new version as active. The issue arises

Xcode 8 Core Data Template for iOS 8,9

二次信任 提交于 2020-01-09 08:51:08
问题 I'm developing an app in a new Xcode 8 and I noticed an obvious thing. Xcode generated me Core Data with the latest API references. So if I change deployment target to iOS 8 or 9, it conflicts and propose me to take in brackets: AVAILABLE my Core Data code. That means I have to write from scratch Core Data code from previous API. Does anybody have template for AppDelegate with both of them or maybe it's possible to make Xcode generate them? Thanks in advance! 回答1: Because no one should have

Should I need to unbind cocoa-bindings in dealloc of windowController?

倖福魔咒の 提交于 2020-01-09 05:26:04
问题 I have window controller and view controller that use core data bindings, but I want to be able to have those views really, truly get deallocated. I then want to reset the managedObjectContext and at that point have given up as much memory as possible. I have found that I am required to unbind things which I've bound in the Nib, or the MOC keeps the Nib objects retained. The issue is this EXEC_BAD_ACCESS trace: If I do not unbind all of the bindings, even those created in Interface Builder,

Check if property is set in Core Data?

独自空忆成欢 提交于 2020-01-08 14:38:15
问题 how can i check if an property is set in an Core Data Object? I load all my Core Data Objects in an Directory: var formQuestions = [Questions]() And my Core Data NSManagementObject is: @NSManaged var noticeText: String formQuestions[indexPath.row].noticeText // load with: var fetchRequest = NSFetchRequest(entityName: "Questions") fetchRequest.predicate = NSPredicate(format: "forms = %@", currentForm!) formQuestions = context.executeFetchRequest(fetchRequest, error: nil) as [Questions] My