nsfetchedresultscontroller

Multiple NSFetchedResultsController - didChangeObject

霸气de小男生 提交于 2019-12-23 21:35:33
问题 I have a UITableView which uses 2 NSFetchedResultsControllers . Each NSFetchedResultsController has only one section. However, the table has 4 sections. I populate the 4th section of the table with the results of one of the NSFetchedResultsControllers . Everything works fine so far. But if the user deletes the first cell on the first section, the NSFetchedResultsControllers are changed. The rows in the last section of the table might be deleted. When this method is called: - (void)controller:

Section names from NSFetchedResultsController don't match the managed object values

↘锁芯ラ 提交于 2019-12-23 18:43:57
问题 I'm using an NSFetchedResultsController to populate a UITableView with results from a moderately sized Core Data store of ~1500 entities. The results controller is fairly standard - some "hot spots" for potential bugs aren't true of this setup. Managed object context created on the same (main) thread as its used on No cache is used (because the sort changes frequently) A sectionNameKeyPath is used to split the results into sections My section results, however, are very odd. For example,

Search NSFetchedResultsController using NSPredicate

只愿长相守 提交于 2019-12-23 16:23:53
问题 I've been stuck on this problem for a while now and have tried my best to work out a solution. I am using Core Data and, being relatively new to iOS coding, I'm having some trouble working out how to search my fetchedResultsController to filter out the string that the user types into the searchBar. I know how to get the string from the searchBar and how to call my fetchResultsController method. But what I'm struggling with is how to use NSPredicate to match only the rows stored in using core

NSFetchedResultsController sections localized sorted

与世无争的帅哥 提交于 2019-12-23 09:18:30
问题 How could I use the NSFetchedResultsController with translated sort key and sectionKeyPath? Problem: I have ID in the property "type" in the database like typeA, typeB, typeC,... and not the value directly because it should be localized. In English typeA=Bird, typeB=Cat, typeC=Dog in German it would be Vogel, Katze, Hund. With a NSFetchedResultController with sort key and sectionKeyPath on "type" I receive the order and sections - typeA - typeB - typeC Next I translate for display and

Strange parent / child NSManagedObjectContext phenomenon

本秂侑毒 提交于 2019-12-23 07:27:17
问题 I have created two context like this: // create writer MOC _privateWriterContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSPrivateQueueConcurrencyType]; [_privateWriterContext setPersistentStoreCoordinator:_persistentStoreCoordinator]; // create main thread MOC _managedObjectContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSMainQueueConcurrencyType]; _managedObjectContext.parentContext = _privateWriterContext; I have a NSFetchResultedController initiated

NSFetchedResultsController section number is 0

自作多情 提交于 2019-12-23 06:14:17
问题 I have the following hierarchy of entities In my TableViewController i have the following code: private lazy var fetchedResultsController: NSFetchedResultsController = { let fetchRequest = NSFetchRequest(entityName: "Worker") let workerTypeSortDescriptor = NSSortDescriptor(key: "workerType", ascending: true) let firstNameSortDescriptor = NSSortDescriptor(key: "firstName", ascending: true) fetchRequest.sortDescriptors = [workerTypeSortDescriptor, firstNameSortDescriptor] guard let stack =

NSFetchedResultsController: using of NSManagedObjectContext during update brings to crash

女生的网名这么多〃 提交于 2019-12-23 01:43:12
问题 Here is the interface of my controller class: @interface ProjectListViewController : UITableViewController <NSFetchedResultsControllerDelegate> { NSFetchedResultsController *fetchedResultsController; NSManagedObjectContext *managedObjectContext; } @end I use following code to init fetchedResultsController : if (fetchedResultsController != nil) { return fetchedResultsController; } // Create and configure a fetch request with the Project entity. NSFetchRequest *fetchRequest = [[NSFetchRequest

Configure NSFetchedResultsController in background when launching Core Data app

无人久伴 提交于 2019-12-22 17:39:09
问题 I have setup a Core Data app with the usual boilerplate code, and the RootViewController initializes the FRC by calling this: - (NSFetchedResultsController *)fetchedResultsController { if (__fetchedResultsController != nil) { return __fetchedResultsController; } // configure the fetchRequest, sectionKey and cacheName __fetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest: fetchRequest managedObjectContext: self.managedObjectContext sectionNameKeyPath: sectionKey

UITableViewAlertForLayoutOutsideViewHierarchy when UITableView doesn't have window iOS13

走远了吗. 提交于 2019-12-22 16:46:33
问题 I started to receive warning (below) on iOS13. I have noticed that this warning pops up because UITableView 's window is null (another tab is selected, pushed detailed view controller on table selection...). I am trying to update UITableView from NSFetchedResultController delegate. What is the correct way to do this on iO13 to keep table updated? Code below worked fine on previous releases. PS: Any kind of beginUpdates , reloadRowsAtIndexPaths:withRowAnimation: , insertSections

Why Can't I delete the bottom row of my UITableView?

北城以北 提交于 2019-12-22 08:05:31
问题 When the user presses Edit, my UITableView adds an insert row at the top (with a green plus), and puts all the other rows into delete mode (red minus). Alternatively, the user can swipe-to-delete without pressing the edit button. I am using a couple of Ivars to keep track of whether the table is in edit mode from a swipe, or from pressing the edit button, and act accordingly (e.g. updating numberOfRowsInTableView: with the extra insert row when Edit has been pressed). Everything works