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
13
votes
3 answers

Reflect changes to objects in a relationship in parent object with NSFetchedResultsController

I have two entities event and time. The event entity has a 1 to many relationship to time entities as each event can be performed multiple times. Now I want to display all the events chronologically in a tableView. So I set up a…
GorillaPatch
  • 5,007
  • 1
  • 39
  • 56
13
votes
4 answers

Core Data: sorting by count in a to-many relationship

I am currently trying to setup a NSFetchedResultsController that will order my table view based on the number of entities in a to-many relationship. I am not sure if this makes a difference when counting, but this is also an inverse relationship. I…
avenged
  • 567
  • 1
  • 8
  • 19
13
votes
2 answers

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'no object at index 3 in section at index 0'

Hi I'm having a hard time fixing this error. Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'no object at index 3 in section at index 0' That error exist when I delete all my Entity in coredata and refetch…
Ron Pelayo
  • 655
  • 2
  • 7
  • 22
12
votes
1 answer

CoreData error driving me crazy... CoreData: Serious application error. An exception caught from delegate of NSFetchedResultsController

My application has two tab bars... Each takes the user to a tableviewcontroller that presents him with a list of items. The first view lets the user record entries in the database. The other tab/view reads from the database and presents those…
12
votes
2 answers

Why does NSTableView crash when processing deleted rows as NSFetchedResultsControllerDelegate?

I am using a fairly standard setup of NSTableView + CoreData + NSFetchedResultsController, with the relevant view controller being NSFetchedResultsControllerDelegate to receive the changes. Here are the relevant bits of code from the view…
Jaanus
  • 17,688
  • 15
  • 65
  • 110
12
votes
3 answers

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

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…
Joseph Astrahan
  • 8,659
  • 12
  • 83
  • 154
12
votes
1 answer

Core Data: Keypath "objectID" not found in entity

I'm using NSFetchedResultsController with a predicate to load a list of Documents in my application. I want to load all the Documents except the currently active one. I am using Rentzsch's MOGenerator to create a _Document class and then I put all…
12
votes
1 answer

NSInvalidArgumentException', reason: 'Invalid predicate: nil RHS, need help figuring this out

I've read other posts about this crash having something to do with the predicate returning nil but im unable to figure this out with my app. Can someone please help me with this? static NSString *const KJMWorkoutCategorySectionKeyPath =…
12
votes
2 answers

unsupported NSSortDescriptor (comparator blocks are not supported)

In fetchedResultsController while setting the NSSortDescriptor iam getting this error unsupported NSSortDescriptor (comparator blocks are not supported). NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; NSEntityDescription *entity =…
Anil Varghese
  • 42,757
  • 9
  • 93
  • 110
12
votes
1 answer

Crash when searching in two section

I have a NSFetchedResultController with different section. I have a crash when I try to search using UISearchDisplayController : *** Assertion failure in -[UITableViewRowData rectForRow:inSection:],…
12
votes
2 answers

Core data: executeFetchRequest vs performFetch

I want a thorough list regarding comparison between the two. Things I have known: executeFetchRequest: Message sent to MOC Return an array of managed objects Goal: fetch objects from persistent store to MOC With table view: has nothing to do with…
12
votes
2 answers

NSRangeException exception in NSFetchedResultsChangeUpdate event of NSFetchedResultsController

I have a UITableView that uses an NSFetchedResultsController as data source. The core data store is updated in multiple background threads running in parallel (each thread using it's own NSManagedObjectContext). The main thread observes the…
Martin R
  • 529,903
  • 94
  • 1,240
  • 1,382
11
votes
4 answers

Add extra row to a UITableView managed by NSFetchedResultsController

I'm using a UITableViewController for a table in my app, and I've added an NSFetchedResultsController to provide the data to show in the table (setting self as it's delegate). However I would like to add a unique cell as the last cell of the table,…
Jon Cox
  • 10,622
  • 22
  • 78
  • 123
11
votes
5 answers

Perform fetch without freezing the UI

I'm making a small chat app. In my app I'm using NSFetchedResultsController. There are 2 tableViews, 1 for lobby and 1 for the chat room. The problem is that whenever I enter a chat room I have to wait for NSFetchedResultsController to perform fetch…
Novarg
  • 7,390
  • 3
  • 38
  • 74
11
votes
3 answers

NSFetchResultController for showing records on an Apple Watch?

Can I use NSFetchResultController on an Apple Watch to show 80 to 90 records in table? I am using WKInterfaceTable+IGInterfaceDataTable to make use of datasource type loading methods because that seems to me simple than using NSArray. Will…
Iqbal Khan
  • 4,587
  • 8
  • 44
  • 83