nsfetchedresultscontroller

UIManagedDocument with NSFetchedResultsController and background context

烈酒焚心 提交于 2019-12-06 15:56:32
问题 I am trying to get the following working. I have a table view that is displaying data fetched from an API in a table view. For that purpose I am using a NSFetchedResultsController: self.fetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:request managedObjectContext:self.database.managedObjectContext sectionNameKeyPath:nil cacheName:nil]; I create my entities in a background context like this: NSManagedObjectContext *backgroundContext; backgroundContext = [

UICollectionView + NSFetchedResultsController in Swift 3

社会主义新天地 提交于 2019-12-06 15:37:05
In my current project I integrated a NSFetchedResultsController with a UICollectionView which works fine. Currently I try to upgrade the project to Swift 3 and Xcode 8 which causes the following error message This application is modifying the autolayout engine from a background thread after the engine was accessed from the main thread. I'm using a BlockOperation array to queue up the changes to the UICollectionView . Here is an example of how I insert a new item. self.blockOperations.append(BlockOperation(block: { collectionView?.insertItems( at: [newIndexPath!]) })) This is my current

NSFetchedResultsController trying to limit number of records displayed

两盒软妹~` 提交于 2019-12-06 15:11:08
问题 When creating a NSFetchRequest to pass over to my NSFetchedResultsController I am setting the fetchLimit property to 3. Now initially this appears to work fine. I can modify the first three returned objects in any way which changes their order and they all reshuffle correctly. The problem appears when I either alter a object which initially fell outside the first three in a way which now brings it into the first three, or when simply adding a new object so it will appear within the first

NSFetchedResultsController delegate fired even when context not saved

喜你入骨 提交于 2019-12-06 13:55:26
问题 I have an NSManagedObject entity which override validateForInsert and validateForUpdate. This methods return NO correctly when something is wrong in object consistency, based on some logic I wrote. The application is a classic uitableview backed by an NSFetchedResultsController, with a detail view controller. When I add a new entity the detail view controller is instantiated with a nil objectID, and pushed into the navigation stack. When I pop the detail controller the [context save:&error]

Table with NSFetchedResultsController move row with adding section

隐身守侯 提交于 2019-12-06 10:49:04
问题 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

NSFetchedResultsController not firing delegate method after merging update from background thread

这一生的挚爱 提交于 2019-12-06 08:15:42
问题 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

NSFetchedResultsControllerDelegate not firing

一曲冷凌霜 提交于 2019-12-06 07:39:51
问题 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*

Customized sort in NSFetchedResultsController

点点圈 提交于 2019-12-06 05:52:48
问题 After spending hours, I found that it was not possible to do customized sort in NSFetchedResultsController backed by SQLite from following article. NSFetchedResultsController custom sort not getting called However, I couldn't find actual solution for my problem. Here's what I am trying to do. Background: I have a English dictionary database (just a simple list of words - very large) in CoreData. Words are shown in UITableView using NSFetchedResultsController. UITableView has an associated

Issue with setting NSSortDescriptor key in NSFetchResultController

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-06 04:59:09
问题 With respect to the above relationship diagram, Earlier, I had a too many relationship between Assignment and Question entity and this is broken to fix a question ordering issue. Now the relationship to Assignment to Question is through a join table AssignmentQuestion. Idea here was to sort the question based on the questionOrderIndex property of the AssignmentQuestion table. I am fetching the assignment questions through a NSFetchResultController. I have written a predicate to fetch the

Configure NSFetchedResultsController in background when launching Core Data app

不打扰是莪最后的温柔 提交于 2019-12-06 04:48:18
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 cacheName: cacheName]; return __fetchedResultsController; } All the sample code I've seen does this.