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
1 answer

How to unit-test NSFetchedResultsController in Swift

I have a Swift app that uses NSFetchedResultsController to fetch List objects from persistent store: let fetchedResultsController: NSFetchedResultsController = ... var error : NSError? fetchedResultsController.performFetch(&error) if let error =…
Darrarski
  • 3,882
  • 6
  • 37
  • 59
8
votes
2 answers

Core Data error: 'Objects must be sorted by section name' for specific languages such as Thai

CoreData: error: (NSFetchedResultsController) The fetched object at index 72 has an out of order section name 'อั. Objects must be sorted by section name' I am using the following code to sort by book title field and display book title's first…
Joshua
  • 1,974
  • 2
  • 23
  • 39
8
votes
1 answer

fetchedResultsController.fetchedObjects.count = 0 but it is full of objects

I am using pretty standard implementation of fetchedResultsController for output in tableView. In the end of -viewDidLoad I am making first call: NSError *error = nil; if (![[self fetchedResultsController] performFetch:&error]) { NSLog(@"Error!…
Olex
  • 1,656
  • 3
  • 20
  • 38
8
votes
1 answer

Core Data backed UITableView with indexing

I am trying to implement a Core Data backed UITableView that supports indexing (eg: the characters that appear down the side, and the section headers that go with them). I have no problems at all implementing this without Core Data using: -…
8
votes
1 answer

NSSortDescriptor to sort by number of items in Core Data To-Many Relationships

It's a long standing problem when using Core Data to-many-relationships that it is very hard to sort a fetch request using NSSortDescriptor on a Parent entity based on the number of children are in a one-to-many relationship to a Child entity. This…
8
votes
2 answers

Locations in Core Data sorted by distance via NSFetchedResultsController?

I have a set of entity objects in my iOS Core Data database that describe something at a location. Let's call the entity Location. I have implemented this by having two attributes on Location that refer to the location - latitude and longitude,…
8
votes
1 answer

Sorting on 'transient' fields with NSFetchedresultController

Is there a way to use a 'transient' field or something like that and in some way sort accordingly with a NSFetchedResultsController. I want to do the following: I have location of places in a database. When a person opens the list, I want to show…
8
votes
2 answers

NSFetchedResultsController's delegate doesn't fire after predicate is changed

I've been troubleshooting this issue for several hours now, no success so far. I've read all question here on SO that might be related to my problem. I've got two Entities (A, B) that are connected to each other in a tree-like structure via a…
8
votes
1 answer

Creating table sections with NSFetchedResultsController

I'm using NSFetchedResultsController to drive the data for my UITableViewController. A simplified version of the managed object I am fetching looks like this (well for example): Person: -(BOOL)hasPet; -(BOOL)hasDog; Basically, I want my table to…
jbrennan
  • 11,943
  • 14
  • 73
  • 115
8
votes
1 answer

UITableView keep the scroll at the correct position while updating NSFetchedResultsController

I am developing an iOS application that mainly use a UITableView. It retrieves pages of articles from a server. We have got >25000 articles; so I have implemented a pull-to-refresh and infinite scrolling to travel across the title collection. The…
8
votes
2 answers

Magical Record, saving, and NSFetchedResultsController

Not sure if this is an issue with the way Magical Record does saves, or I'm just making an noob mistake somewhere. I'm using an NSFetchedResultController (FRC) and UITableView to display a list of entities, when the user taps "Add" a new View…
7
votes
1 answer

FetchResultController delegate - incompatible types warning

I'm trying to connect my CoreData to iCloud using NSFetchedResultController basing on iCloud example. NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest…
Nat
  • 12,032
  • 9
  • 56
  • 103
7
votes
1 answer

NSFetchedResultsController / Parent-Child

I'm working on my first Core Data-backed app and am having trouble figuring out how to set up an NSFetchedResultsController properly. I have two entities: /-----------\ /-----------\ | List | | ListItem | | --------- | |…
7
votes
4 answers

How do I refresh/reload to update changes to my predicate & thus fetch request?

Hi I currently have a table view which is being filled via Core Data. I am limiting the results using NSPredicate so that only items with the same OrderNumber are displayed in the tableView. NSPredicate *predicate = [NSPredicate…
7
votes
2 answers

Does NSFetchedResultsController Observe All Changes to Persistent Store?

My program does work like link below: Update results of NSFetchedResultsController without a new fetch show result of NSFetchedResultsController to UITableView get new object from web service and store it to core data (in same view controller, with…