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

TableView with two instances of NSFetchedResultsController

After days of research and re-coding I am pretty much stumped. My goal is to get a test app running with a single tableview populated from two separate fetchedResultControllers. I have a series of items on a shopping list, each with a department…
Ben Packard
  • 26,102
  • 25
  • 102
  • 183
8
votes
1 answer

NSFetchedResultsController objectAtIndex, objectAtIndexPath, indexPathForObject inconsistencies

I have a fetched result with a single section. I am able to access the objects using [[fetchedResultsController fetchedObjects] objectAtIndex:index] for all of the objects. But it is failing when I use objectAtIndexPath like this:…
Jim
  • 5,940
  • 9
  • 44
  • 91
8
votes
2 answers

iOS - Core Data - Multiple NSFetchedResultsController in one UIViewController

I'm trying to build an iPad app working with Core Data. But I'm facing a design and a coding issue. Let's say I add one UIViewController to my window and inside that viewcontroller, I need to display two tableviews (2 different entities) and 2 views…
Dabrut
  • 862
  • 1
  • 10
  • 25
8
votes
4 answers

is it possible to get distinct results when using an NSFetchedResultsController?

I have a product search that searches the ProductCategories my products are in, sometimes my products are in multiple categories which gives me duplicate results. I don't want to search the product table directly because there are several products…
Slee
  • 27,498
  • 52
  • 145
  • 243
8
votes
1 answer

NSFetchedResultsController duplicated rows

I'm experiencing a weird behavior when using a secondary thread to refresh NSFetchedResultsController contents and I'd like to know it this is a common issue or I might be doing something wrong. I've got a centralized NSManagedObjectContext residing…
8
votes
6 answers

Core Data: Background fetch, NSFetchedResultsController and Sorting time

the problem I am encountering is the following: I have a UITableView which I feed with data from an NSFetchedResultsController which retrieves around 6000 rows from core data. The fetchBatchSize of the NSFetchRequest is set to 20 and if I do not…
monchote
  • 3,440
  • 2
  • 20
  • 20
8
votes
3 answers

NSFetchedResultsController custom sort not getting called

I am currently trying to populate a UITableView in my project from Core Data using NSFetchedResultsController. I am using a custom search with a comparator (although I have also tried a selector and had an identical problem): if…
8
votes
1 answer

NSFetchedResultsController returns duplicates (the same objectID and reference)

I'm experiencing a weird behaviour with NSFetchedResultsController. It is new in iOS 10. Straight to the point: fetchedObjects contains duplicate objects. This is not by any mean "duplicate" in my own criteria. They literally have the same objectIDs…
msmialko
  • 1,439
  • 2
  • 20
  • 35
8
votes
2 answers

NSFetchedResultsSectionInfo disagrees with itself about how many objects it has

I posted this on the Apple dev forums here since it feels to me like a bug in the actual SDK, but I thought I'd post it here as well and see if anyone could verify whether or not I'm using this thing incorrectly (doesn't seem like it) or this is…
glenc
  • 3,132
  • 2
  • 26
  • 42
8
votes
2 answers

NSFetchedResultsController complex fetch request and model

I'm trying to design my CoreData model for this situation: We have Song object which have to-many relationship with some List. Each List have name property and also have to-many relationship with Song These many-to-many relationship is needed…
Artem Shmatkov
  • 1,434
  • 5
  • 22
  • 41
8
votes
4 answers

Multiple NsfetchedResultsController on a UItableView

I'm having difficulty implementing 2 nsfetchedresultsController in a tableView. I wanted a fetchedresultsController in each section of the table (2 sections), something like this: Wishlist product product2 Bought product3 I know that for this…
8
votes
2 answers

Core Data NSFetchedResultsController and batch size set loads all rows

I have thousands of points in my Core Data database and I would like to have all them in my tableView but I don't want to fetch them to memory all at once but I would like to use NSFetchedResultsController and batch them with some constant. I set it…
8
votes
1 answer

NSFetchedResultsController consistent delay in updating UITableView cell; insert works instantaneously

I have a UITableView (with custom cells, if that matters) hooked up to an NSFetchedResultsController. My app also uses push notifications. When a remote notification arrives, I update my (core)data model in two phases: 1) Get title (with some custom…
8
votes
3 answers

NSFetchedResultsController sections localized sorted

How could I use the NSFetchedResultsController with translated sort key and sectionKeyPath? Problem: I have ID in the property "type" in the database like typeA, typeB, typeC,... and not the value directly because it should be localized. In English…
Gerd
  • 328
  • 1
  • 2
  • 9
8
votes
2 answers

Make UITableView keep scroll position when adding cells at top

Ok so what I need is to prevent tableview scrolling when new elements added above current visible row. I'm using NSFetchedResultsController with a lot of objects (like 10 000) and reloadData works pretty smooth when I'm not touching…