Questions tagged [nsfetchedresultscontroller]

An Apple fetched results controller is used to efficiently manage the results returned from a Core Data fetch request to provide data usually for a UITableView or UICollectionView object. It is available in iOS 3.0 and later.

An Apple controller used to efficiently manage the results returned from a Core Data () fetch request to provide data for a UITableView or UICollectionView object.

From Apple Official NSFetchedResultsController Document, fetched results controllers provide the following features:

  • Optionally monitor changes to objects in the associated managed object context, and report changes in the results set to its delegate (see: The Controller’s Delegate).

  • Optionally cache the results of its computation so that if the same data is subsequently re-displayed, the work does not have to be repeated (see: The Cache).

Example:

NSFetchedResultsController *controller = [[NSFetchedResultsController alloc]
    initWithFetchRequest:fetchRequest
    managedObjectContext:context
    sectionNameKeyPath:nil
    cacheName:@"<#Cache name#>"];

[fetchRequest release];

Questions in Stack overflow related coredata

  1. Good tutorials or good for using Core.Data in IOS 7

  2. JSON and Core Data on the iPhone

  3. Why use NSFetchedResultsController?

2287 questions
9
votes
2 answers

UITableViewAlertForLayoutOutsideViewHierarchy when UITableView doesn't have window iOS13

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…
Marek H
  • 5,173
  • 3
  • 31
  • 42
9
votes
2 answers

Reordering Cells with UICollectionViewDiffableDataSource and NSFetchedResultsController

I'm using a UICollectionViewDiffableDataSource and a NSFetchedResultsController to populate my UICollectionView inside my UIViewController. To add the ability of reordering cells I added a UILongPressGestureRecognizer and subclassed…
9
votes
1 answer

NSFetchedResultsController deleteCache in Swift 3

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…
HavenB3
  • 129
  • 1
  • 6
9
votes
1 answer

Swift: Unable to infer complex closure type with NSFetchedResultsController

After upgrading my project to Swift 3, the following initializer no longer builds: 1 var fetchedResultsController: NSFetchedResultsController { 2 if _fetchedResultsController != nil { 3 return _fetchedResultsController! 4 …
cleverbit
  • 5,514
  • 5
  • 28
  • 38
9
votes
4 answers

UITableView Freezes After Swipe to Delete But Not Whole UI

Full-screen table view iPad-only app. I have enabled swipe to delete on my rows. The row animation always finishes after the delete (commitEditingStyle completes), but occasionally the entire table view freezes. Not the whole UI, mind you, so it's…
Matt Long
  • 24,438
  • 4
  • 73
  • 99
9
votes
1 answer

Core Data NSFetchedResultsController not updated after a batchUpadate on the device but ok on simulator

I have a NSFetchedResultsController that managed my UITableView data source. I am trying to modify a property of a NSManagedObject called amountToCompute using a NSBatchUpdateRequest. So I create the batch update: let batchUpdate =…
Nico
  • 6,269
  • 9
  • 45
  • 85
9
votes
3 answers

Core Data NSPredicate for relationships doesn't work after [context save]

I have two entities in Core Data (see below), and using NSFetchedResultsController with [NSPredicate predicateWithFormat:@"calendar.subscribed == 1"]; to extract "Event" object. Calendar subscribed (BOOL) events (one-to-many relationship to…
Yuwen Yan
  • 4,777
  • 10
  • 33
  • 63
9
votes
3 answers

How to refresh a UITableViewController or NSFetchedResultsController?

I have a little problem with my UITableViewController or NSFetchedResultsController. I am not sure which is the problem soure but I guess its the UITableViewController. As I said I use a NSFetchedResultsController to fill my data into a …
elementsense
  • 1,540
  • 3
  • 15
  • 21
9
votes
2 answers

Design pattern for Core Data iPhone App

Im building an app that will use a Core Data model. I pretty new at Objective C and my usual design patterns does not really apply on Core Data and Objective C, at least I can't seem to find examples that confirms they will. I have been through the…
9
votes
3 answers

UICollectionView with Multiple subclassed UICollectionViewCell

I have multiple sections in my UICollectionView grouped by "datasetType". I also have a custom UICollectionViewCell for each section. How can I determine which custom UICollectionViewCell I need in the cellForItemAtIndexPath method? My first though…
9
votes
0 answers

NSFetchedResultsController calls controllerDidChangeContent delegate multiple times with stale results?

I've got a coredata model setup like this: TileList <->> TileListOrder TileListOrder <<-> Tile And a NSFetchedResultsController created with: NSPredicate* predicate = [NSPredicate predicateWithFormat:@"tile <> nil AND tileList <> nil AND…
Sérgio
  • 101
  • 3
9
votes
3 answers

NSFetchedResultsChangeUpdate fired instead of NSFetchedResultsChangeDelete

I have a NSFetchedResultsController initiated in the following way: NSEntityDescription *myEntity = [NSEntityDescription entityForName:@"MyEntity" inManagedObjectContext:managedObjectContext]; NSFetchRequest *fetchRequest = [[NSFetchRequest alloc]…
Natan R.
  • 5,141
  • 1
  • 31
  • 48
9
votes
2 answers

NSFetchedResultsController doesn't see new inserts / removes fetched values after update

After reading dozens of similar questions, I'd like to start with this statement: "I DID set the delegate of the NSFetchedResultsController, it didn't work.". So I have a simple TableViewController whose cells are filled with…
Arseniy
  • 487
  • 4
  • 14
9
votes
2 answers

Saving Single CoreData Entity (Not the Whole Context) While Keeping NSFetchedResultController Functionality

Phew, sorry for the long title. I have a single Managed Object Context where I am storing songs derived from two different locations. I get some of the songs from the persistent storage on the phone (using Core Data), and I pull some of the songs…
8
votes
1 answer

NSPredicate and CoreData - decide if a Date attribute is "today" (or between last night 12am to tonight 12am) on iOS

I'm using a NSFetchedResultsController and a UITableViewController to populate a UITableView from a CoreData database. I have a NSDate object saved into this Date attribute labeled "startTime". Then I'm trying to only pull todays's data by using a…