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
17
votes
2 answers

NSFetchedResultsController with search

What is the best practice to filter the NSFetchedResultsController data? do i need to re-initialize it every time the searchbar's text changes? I am using a UISearchDisplayControllers and i'm implementing: -…
Guy
  • 12,488
  • 16
  • 79
  • 119
17
votes
4 answers

UITableView contentSize

Having a problem with a couple of table views in my app. The problem happens when the contents of the table changes (and therefore the content of the tableview gets bigger). For some reason the contentSize of the UITableView stays the same meaning I…
Fogmeister
  • 76,236
  • 42
  • 207
  • 306
17
votes
2 answers

NSFetchedResultsController - different sort order than section name

I have an NSManagedObject for the sections in the grouped UITableView. This object has the attributes "name" and "createdAt". I want to use "name" in te UI for the section titles, but sorted by "createdAt". According to the documentation the first…
Sebastian
  • 3,379
  • 2
  • 23
  • 39
16
votes
2 answers

iOS crash 'NSInternalInconsistencyException', reason: 'statement is still active' Core Data cache related?

Very occasionally seeing these pop up in crash reports on screens using NSFetchedResultsController, and not sure how to address them. I don't believe I'm using threading anywhere, unless NSFetchedResults is using them…
Bob Spryn
  • 17,742
  • 12
  • 68
  • 91
16
votes
1 answer

'NSFetchedResultsController does not support both change tracking and fetch request's with NSDictionaryResultType'

I have an application that was running just fine under OS3+. But it does not work under OS4. I get the following error message: 'NSFetchedResultsController does not support both change tracking and fetch request's with…
16
votes
1 answer

Transient sectionNameKeyPath & NSSortDescriptor NSFetchedResultsController

I have a list of tasks within Core Data. I fetch them into a UITableView using an NSFetchedResultsController. I need custom sections in a custom order: OVERDUE ACTIVE ONGOING POSTPONED COMPLETED To determine what section a task should go in I…
Timbo
  • 1,214
  • 1
  • 16
  • 32
15
votes
1 answer

Matt Gallagher's UITableView (Revisited) + NSFetchedResultsController

If you look at Matt Gallagher's Cocoa With Love blog, he has a brilliant discussion (with sample code) on a fresh a beautiful retake on UITableView ... In the post, he talks about it's great many benefits of animations and heterogeneous cells, etc.…
Greg Combs
  • 4,252
  • 3
  • 33
  • 47
15
votes
4 answers

Add new attribute to existing Core Data Entity Relationship

I'm not sure if my understanding of Core Data relationships is flawed as I can't seem to achieve what I want to do. I have a 2 entities created to manage Chat on the app and a one-to-Many relationship between the users and the messages. So a user…
15
votes
2 answers

NSFetchedResultsController prepend a row or section

I have a UITableView populated with a standard NSFetchedResultsController. However I'd like to prepend a row or a section (row preferably but either would works fine really.) The only way I can possibly see doing this right now is to rewrite all the…
Philip
  • 769
  • 7
  • 20
14
votes
4 answers

NSFetchedResultsController v.s. UILocalizedIndexedCollation

I am trying to use a FRC with mixed language data and want to have a section index. It seems like from the documentation you should be able to override the FRC's - (NSString *)sectionIndexTitleForSectionName:(NSString *)sectionName - (NSArray…
14
votes
1 answer

Correctly use of NSFetchedResultsController cache

I am using a NSFetchedResultsController for dealing with a UITableView and everything works fine and I found it very powerful, especially in conjunction with the results delegate. For drilling down the table I am reusing the same controller class,…
Leonardo
  • 9,607
  • 17
  • 49
  • 89
14
votes
1 answer

Add additional argument to an existing NSPredicate

Is it possible to take an existing NSPredicate and add an additional argument to it? In one of my tableviews I am passing in a NSPredicate to use in for my NSFetchedResultsController like so: [fetchedResults setPredicate:self.predicate]; This is…
avenged
  • 567
  • 1
  • 8
  • 19
14
votes
3 answers

How to use NSFetchedResultsController and UISearchDisplayController

I've been creating an iPhone App using Core Data. First of all, does it make sense to use an NSFetchedResultsController and a UISearchDisplayController together to fetch the result? Would you recommend something else? I've been trying quite long…
14
votes
1 answer

NSFetchedResultsController doesn't call controllerDidChangeContent: after update to non-fetched NSManagedObject

I populate and save: an initial NSManagedObjectContext setup an NSFetchedResultsController with a different NSManagedObjectContext, which filters on a boolean "show" attribute. Finally update "show" on yet another NSManagedObjectContext and…
Heath Borders
  • 30,998
  • 16
  • 147
  • 256
13
votes
5 answers

Delete row in table view with fetchedResultController

During swype deleting (most importatnt lines of this method): - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { if (editingStyle ==…
Nat
  • 12,032
  • 9
  • 56
  • 103