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

Core Data: UITableView with multiple NSFetchedResultControllers

What I want to do is pretty simple. In my UITableViewController, I want to load data from multiple NSFetchedResultControllers (I have multiple entities in my data model) and put data from each one into a different section in the table view. So for…
indragie
  • 18,002
  • 16
  • 95
  • 164
28
votes
3 answers

Changing a managed object property doesn't trigger NSFetchedResultsController to update the table view

I have a fetchedResultsController with a predicate, where "isOpen == YES" When calling for closeCurrentClockSet, I set that property to NO. Therefore, it should no longer appear on my tableView. For Some Reason, this is not happening. Can someone…
27
votes
2 answers

NSFetchedResultsController with predicate ignores changes merged from different NSManagedObjectContext

I am presenting table view contents using NSFetchedResultsController which has a predicate: [NSPredicate predicateWithFormat:@"visible == %@", [NSNumber numberWithBool:YES]] On background thread using separate NSManagedObjectContext I update few of…
ampatspell
  • 844
  • 7
  • 10
26
votes
1 answer

Why use NSFetchedResultsController?

Core data provides the method "executeFetchRequest" in NSManagedObjectContext class, which we can use to fetch data from tables and use it whatever the way need to. Now there is another way by using NSFetchedResultsController and providing it to…
Ansari
  • 1,907
  • 2
  • 23
  • 34
26
votes
2 answers

NSFetchRequest and predicateWithBlock

I am playing with an app that uses Core Data and NSManagedObjects to populate a UITableView. There is only one class in my application, called Event. I have created the following custom instance method on Event: - (BOOL)isExpired { return…
25
votes
1 answer

NSFetchedResultsController attempting to insert nil object

Edit 7: Here's my save method. It's pretty boilerplate. The DEBUG_LOG() macros are only executed if it's a debug build. - (void)saveManagedObjectContext:(NSManagedObjectContext *)moc { if ([moc hasChanges]) { DEBUG_LOG(@"Saving managed…
25
votes
5 answers

NSPredicate: Fetch one of each kind

I want to create an NSFetchRequest for objects like this: The Object is Car which has an attribute color. I have four cars: car1.color = red car2.color = red car3.color = blue car4.color = green I want to create an NSPredicate that selects only one…
arnoapp
  • 2,416
  • 4
  • 38
  • 70
23
votes
7 answers

NSFetchedResultsController ignores fetchLimit?

I have a NSFetchedResultsController to update a UITableView with content from Core Data. It's pretty standard stuff I'm sure you've all seen many times however I am running into slight problem. First here's my code: NSFetchRequest *fetchRequest =…
marchinram
  • 5,698
  • 5
  • 47
  • 59
23
votes
5 answers

A NSFetchedResultsController with date as sectionNameKeyPath

I develop an application which uses Core Data. In one UITableView, I want to display a list of my entities, sorted by the saved date of the objects. When I do this: fetchedResultsController = [[NSFetchedResultsController alloc] …
Paul Warkentin
  • 3,899
  • 3
  • 26
  • 35
23
votes
2 answers

NSFetchedResultsController doesn't show updates from a different context

I have an NSFetchedResultsController and a few operations updates managed objects on separate threads via NSOperationQueue. The FRC (with its predicate) looks like this: - (NSFetchedResultsController*)fetchedResultsController { …
22
votes
2 answers

Core data: The fetched object at index x has an out of order section name 'xxxxxx. Objects must be sorted by section name

I know I'm not the first to ask this question but I'm really stumped.. Basically I have a screen with two buttons. Each button loads data into a tableview below based on a date. On the first load of the first tableview (the left button is selected…
sixstatesaway
  • 1,106
  • 1
  • 12
  • 25
21
votes
2 answers

NSFetchedResultsController calls didChangeObject delete instead of update

This is the code, I save the model via Magical Record: MagicalRecord.saveWithBlock({ (localContext) -> Void in var localNotification = CDNotification.MR_findFirstByAttribute("notificationID", withValue:…
vburojevic
  • 1,666
  • 5
  • 24
  • 34
19
votes
4 answers

Changing the Sorting in an NSFetchedResultsController on the fly

I'm trying to change the sorting in a NSFetchController on the fly, by some sort of segmented control. To either sort A->Z Z->A type thing. What do I have to do to do this? I'm following Jeff Lamarche's example here: Here Do I need to make a new…
aleclerc
  • 707
  • 2
  • 7
  • 11
18
votes
5 answers

Serious Application Error in Core Data with fetchedResultsContainer

I get the following error when trying to add a record: Serious application error. Exception was caught during Core Data change processing. This is usually a bug within an observer of NSManagedObjectContextObjectsDidChangeNotification. …
Christoph
  • 1,580
  • 5
  • 17
  • 29
17
votes
7 answers

Bounce occurs when changing rows

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…
J. Doe
  • 12,159
  • 9
  • 60
  • 114