nsfetchedresultscontroller

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

血红的双手。 提交于 2019-12-04 19:44:04
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 ( controllerDidChangeContent etc) don't get called when a new Item object is inserted. The FRC and NSFetchRequest use the Main

Table with NSFetchedResultsController move row with adding section

自作多情 提交于 2019-12-04 18:09:06
I have UITableView with NSFetchedResultsController NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:[self dataFetchRequest] managedObjectContext:[MLCoreDataService sharedInstance].managedObjectContext sectionNameKeyPath:@"checked" cacheName:nil]; aFetchedResultsController.delegate = self; I've implemented - (void)controller:(NSFetchedResultsController *)controller didChangeObject:(id)anObject atIndexPath:(NSIndexPath *)indexPath forChangeType:(NSFetchedResultsChangeType)type newIndexPath:(NSIndexPath *)newIndexPath { UITableView

Updating fetchedResultsController for predicate set by UISearchBar

淺唱寂寞╮ 提交于 2019-12-04 17:27:01
Refactored to vanilla UIViewController Rather than having the UITableView toggle between active and inactive UISearchController , I refactored to a vanilla UIViewController with a UISearchBar at the top and a UITableView directly underneath it. What I'm trying to do is toggle the fetchedResultsController between having a predicate which is set by the text in the searchBar and one that grabs everything. I found this answer, which describes a solution to a similar problem in Objective-C and served as the basis upon which I refactored my Swift project: How to filter NSFetchedResultsController

FetchedResultsController Swift 3 API Misuse: Attempt to serialize store access on non-owning coordinator

删除回忆录丶 提交于 2019-12-04 17:13:45
问题 I'm attempting to use a fetchedResultsController to handle the results in my UITable. It works initially when the program starts up. Then when I switch back to the inventory tab where my table is (for the viewToAppear again), this is when it crashes. I'm getting a runtime crash error in my viewWillAppear() method of the window which has the table. In particular it crashes on the Inventory+CoredataProperties.swift file on this line let characters = name!.characters.map { String($0) } , but I

Coredata object fault in independent ManagedObjectContext vs changes in persistent store

偶尔善良 提交于 2019-12-04 16:33:56
I have an operation object which creates it's own Managed Object Context. The operation object performs calculation basically to take off load from main thread while main thread concentrates on the UI aspect. This operation object's MOC shares a common persistent store across the application. It sometimes happens such that, while the operation is being performed, the MOC of main thread is notified of changes in backend. So, I try to merge the changes of MOC, where some of the deletions in model objects might happen. In some rare cases, as I observe, the operation object might not have been

Bounce occurs when changing rows

可紊 提交于 2019-12-04 16:22:19
问题 Glitch I am using CoreData with a NSFetchResultController to have data displayed in a UITableView . I have one problem: the UITableView changes the contentOffSet.y when a new row is inserted/moved/deleted. When the user have scrolled to, for e.g. the middle, the UITableView bounces when a new row is inserted. Reproduction project This github link to a project which contains the minimum code to reproduce this behavior: https://github.com/Jasperav/FetchResultControllerGlitch (the code is down

NSFetchedResultsControllerDelegate not firing

谁说我不能喝 提交于 2019-12-04 14:56:26
I can't figure out why, for the life of me, the NSFetchedResultsControllerDelegate methods are not firing when I add data to the underlying datastore. The data shows up immediately if I restart the iPhone application. I have subclassed UITableViewController and conform to NSFetchedResultsControllerDelegate: @interface ProjectListViewController : UITableViewController <NSFetchedResultsControllerDelegate> { NSFetchedResultsController* fetchedResultsController_; NSManagedObjectContext* managedObjectContext_; } I instantiate the NSFetchedResultsController and set the delegate to self: //

iPhone contacts app styled indexed table view implementation

青春壹個敷衍的年華 提交于 2019-12-04 14:51:43
问题 My Requirement: I have this straight forward requirement of listing names of people in alphabetical order in a Indexed table view with index titles being the starting letter of alphabets (additionally a search icon at the top and # to display misc values which start with a number and other special characters). What I have done so far: 1. I am using core data for storage and "last_name" is modelled as a String property in the Contacts entity 2.I am using a NSFetchedResultsController to display

NSFetchedResultsController not firing delegate method after merging update from background thread

安稳与你 提交于 2019-12-04 13:20:56
I have an NSFetchedResultsController and a few operations that inserts and updates managed objects on separate threads via NSOperationQueue. The FRC looks like this, note that I have set the cache to nil: [NSFetchedResultsController deleteCacheWithName:nil]; NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:managedObjectContext sectionNameKeyPath:nil cacheName:nil]; Each threaded operation has its own managed object context and fires mergeChangesFromContextDidSaveNotification to the main MOC each

NSFetchedResultsController is loading all rows even through I have batch set

烂漫一生 提交于 2019-12-04 13:06:27
问题 Ok. This is the exact same question as here: Why is NSFetchedResultsController loading all rows when setting a fetch batch size? But the solution for his doesn't solve for mine. I have a screen that has several thousand records and is slow to load them all. I set the batch size to 30 (roughly three times the cells on the screen) and it still loops through and loads all the batches for some reason. Here is the code - (NSFetchedResultsController *)guestCardFetchedResultsController { if