nsfetchedresultscontroller

Core data - Building a NSPredicate from a ManyToMany relationship

大憨熊 提交于 2020-01-03 04:50:14
问题 This is a follow up question to my previous question on: Core data: Managing employee contracts in a many-to-many relationship? There is a diagram on that question, and as a quick reminder there is the following: company --< contracts >-- employees I have been able to manually save 1 entity inside each of the entities, and verified them all in NSLog. I've created a CompanyListPage which lists all companies. The idea is that when you click on a company you will be presented with a list of all

NSFetchedResultsController does not update TableView after UIManagedDocuments gets new data

限于喜欢 提交于 2020-01-03 03:34:13
问题 I am using a NSFetchedResultsController in combination with a UIManagedDocument which gets updated in an background thread. I have set up the NSFetchedResultsController exactly as described in this tutorial: How To Use NSFetchedResultsController I have set the delegate _fetchedResultsController.delegate = self and the protocol for my view controller to NSFetchedResultsControllerDelegate . My code works fine when it loads the data after launch. However, the NSFetchedResultsController does not

Using NSSortDescriptor to keep 'nil' values at the bottom of a list

家住魔仙堡 提交于 2020-01-02 08:07:39
问题 I'm working on sorting NSFetchedResultController data. I need to sort data by their first name. However, there are some entries with no first name. I need the "no first name" objects to appear the bottom of the list, rather than the top. With the current code, when I sort the list by first name, the "no first name" cells are placed at the top. NSFetchRequest *request = [NSFetchRequest fetchRequestWithEntityName:@"Contacts"]; request.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:

UITableView not updating DataSource after change to NSFetchedResultsController

那年仲夏 提交于 2020-01-02 04:47:07
问题 I have an UITableView populated by a NSFetchedResultsController . The initial fetch works fine. I can add, remove, modify, etc with zero problems.. But I want to add user-defined sorting to the table. I am doing this by changing the NSFetchedResultsController to use a different sortDescriptor set, and a different sectionNameKeyPath . Here is the code where I change the fetch: -(void)changeFetchData { fetchedResultsController = nil; NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];

unsupported NSSortDescriptor (comparator blocks are not supported)

淺唱寂寞╮ 提交于 2020-01-02 01:21:06
问题 In fetchedResultsController while setting the NSSortDescriptor iam getting this error unsupported NSSortDescriptor (comparator blocks are not supported) . NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:@"Alarm" inManagedObjectContext: managedObjectContext]; [fetchRequest setEntity:entity]; //Below code is not working and causing error. sorting use the hours&seconds part of the time attribute NSSortDescriptor *sort

CoreData: Private context with child Main context - FetchedResultsController not getting updates

本小妞迷上赌 提交于 2020-01-01 19:42:02
问题 I've been trying to build a Core Data stack as described by Marcus Zarra, where he has a Private Queue context and a Main Queue context (where the Main Queue context is a child of the Private Queue context). I believe I've correctly rebuilt (here) his described MCPersistenceController faithfully in Swift (the example code was Obj-C). The problem is in my ListViewModel class (which contains an NSFetchedResultsController ). No matter what I try, its delegate callbacks (

CoreData: Private context with child Main context - FetchedResultsController not getting updates

狂风中的少年 提交于 2020-01-01 19:41:15
问题 I've been trying to build a Core Data stack as described by Marcus Zarra, where he has a Private Queue context and a Main Queue context (where the Main Queue context is a child of the Private Queue context). I believe I've correctly rebuilt (here) his described MCPersistenceController faithfully in Swift (the example code was Obj-C). The problem is in my ListViewModel class (which contains an NSFetchedResultsController ). No matter what I try, its delegate callbacks (

NSFetchedResultsController deleteCache in Swift 3

老子叫甜甜 提交于 2020-01-01 09:05:48
问题 Currently migrating to swift 3 and can't quite figure out what the parser wants for NSFetchedResultsController.deleteCache(withName: "rootCache") With this syntax, I'm getting a "Type 'String?' does not conform to protocol 'ExpressibleByStringLiteral'" error when building. 回答1: The error message is misleading. As of Swift 3, NSFetchedResultsController is a generic type open class NSFetchedResultsController<ResultType : NSFetchRequestResult> : NSObject { } and the following should work:

NSFetchedResultsController deleteCache in Swift 3

烂漫一生 提交于 2020-01-01 09:05:06
问题 Currently migrating to swift 3 and can't quite figure out what the parser wants for NSFetchedResultsController.deleteCache(withName: "rootCache") With this syntax, I'm getting a "Type 'String?' does not conform to protocol 'ExpressibleByStringLiteral'" error when building. 回答1: The error message is misleading. As of Swift 3, NSFetchedResultsController is a generic type open class NSFetchedResultsController<ResultType : NSFetchRequestResult> : NSObject { } and the following should work:

NSFetchedResultsController based Table View always fails on SECOND insert of entity

 ̄綄美尐妖づ 提交于 2020-01-01 05:31:25
问题 I am using an NSFetchedResultsController to manage displaying fetched managed objects in a table view that has one section. The table starts out empty and the user can add new entities to it using the UI. As it stands, the program always works when adding the first entity, and always crashes when adding a second. There is sometimes no error presented upon the crash and other times there are errors of differing types (some included below). Through log statements and tracing I see that the