nsfetchrequest

Not update Table after saving or updating Core data - Swift

风格不统一 提交于 2020-01-15 10:16:15
问题 I have bellow class for my CRUD in my project: class ProjectCoreDataStore: DegreesProtocol, DegreesStoreUtilityProtocol { // MARK: - Managed object contexts var mainManagedObjectContext: NSManagedObjectContext var privateManagedObjectContext: NSManagedObjectContext // MARK: - Object lifecycle init() { //let fileName: String = "PortalMDBApp.sqlite" let fileName: String = "MDB.sqlite" let fileManager:FileManager = FileManager.default let directory = fileManager.urls(for: .documentDirectory, in:

Not update Table after saving or updating Core data - Swift

送分小仙女□ 提交于 2020-01-15 10:16:08
问题 I have bellow class for my CRUD in my project: class ProjectCoreDataStore: DegreesProtocol, DegreesStoreUtilityProtocol { // MARK: - Managed object contexts var mainManagedObjectContext: NSManagedObjectContext var privateManagedObjectContext: NSManagedObjectContext // MARK: - Object lifecycle init() { //let fileName: String = "PortalMDBApp.sqlite" let fileName: String = "MDB.sqlite" let fileManager:FileManager = FileManager.default let directory = fileManager.urls(for: .documentDirectory, in:

NSFetchRequest not catching objects that have a changed property

淺唱寂寞╮ 提交于 2020-01-14 13:28:11
问题 I have run into a weird problem with CoreData on MacOsX 10.6 using an SQL store. I have an NSManagedObject subclass called Family with attribute name and a relationship personList connected to another NSManagedObject subclass called Person with attribute firstname and inverse relationship family . A Person has only one family , and a family can have several Person s. Say I have a Family object family pointing to the family 'Doe' with 2 Person (John and Jane) connected to it and I do the

Swift 3 - NSFetchRequest Distinct Results

柔情痞子 提交于 2020-01-13 08:17:03
问题 Any help appreciated. Xcode auto updated to 8... I am Targeting IOS 9.3 Have all of the code converted across but one thing is now breaking, I have tried various suggestions in similar questions! My fetch request that was previously working is now breaking. My goal is to get a distinct list. The app crashes on the line: let results = try context.fetch(fetchRequest) With the error described in the console as: Could not cast value of type 'NSKnownKeysDictionary1' (0x10fd29328) to 'MyApp

Swift 3 - NSFetchRequest Distinct Results

♀尐吖头ヾ 提交于 2020-01-13 08:16:52
问题 Any help appreciated. Xcode auto updated to 8... I am Targeting IOS 9.3 Have all of the code converted across but one thing is now breaking, I have tried various suggestions in similar questions! My fetch request that was previously working is now breaking. My goal is to get a distinct list. The app crashes on the line: let results = try context.fetch(fetchRequest) With the error described in the console as: Could not cast value of type 'NSKnownKeysDictionary1' (0x10fd29328) to 'MyApp

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

Sorting NSFetchedResultsController by Swift Computed Property on NSManagedObjectSubclass

人走茶凉 提交于 2020-01-11 02:04:54
问题 I'm building an app using Swift with Core Data. At one point in my app, I want to have a UITableView show all the objects of a type currently in the Persistent Store. Currently, I'm retrieving them and showing them in the table view using an NSFetchedResultsController . I want the table view to be sorted by a computed property of my NSManagedObject subclass, which looks like this: class MHClub: NSManagedObject{ @NSManaged var name: String @NSManaged var shots: NSSet var averageDistance: Int{

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

group by date (yyyy/MM/dd) with NSFetchRequest

女生的网名这么多〃 提交于 2020-01-07 05:44:08
问题 i have to count and group on more that 3 properties. i'm pulling my hair while grouping and counting on field with date (yyyy/mm/dd HH:mm:ss) i want to group by year - month - day and ignore the time. but i still need the time for detail view. time zone plays a big role here. so i just save it in utc format. NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:@"logs" inManagedObjectContext:context;