FAQ Database Discussion Community


Why my NSFetchedResultsController loads all rows?

ios,objective-c,core-data,nsfetchedresultscontrolle,nsfetchrequest
I have a NSFetchedResultsController used to display data in a table view (22117 rows). The fetchBatchSize is set to 20 on the fetchRequest. It works as expected: only 20 rows are fully populated when the table view is loaded. SQL statements: 2015-06-12 17:59:55.526 BoulderFinder[2228:1220755] CoreData: sql: SELECT 0, t0.Z_PK FROM...

Getting UITableView header titles from NSDate

ios,uitableview,tableview,nsfetchedresultscontrolle
I’m populating a tableview with data from Core Data via MagicalRecord. I want the tableview to be displayed in chronological order, sectioned by date, also in chronological order. First, I obtain the sortDate from the transDate, from modified code I found on the web: // Gives beginning of this day...

Edit TableView containing NSFetchedResults

ios,objective-c,uitableview,nsfetchedresultscontrolle
When deleting an object from my Core Data that is fetched using NSFetchedResultsController and displayed in a TableView, it does not update the table. It deletes the object just fine however the row remains there until I swap views and return. I have noticed that this issue has only started...

Order of sections produced by NSFetchedResultsController?

ios,core-data,ios8,nsfetchedresultscontrolle
Does a NSFetchedResultsController assign values for the attribute identified by sectionNameKeyPath to sections always in ascending order? For instance if my sectionNameKeyPath were an (optional) boolean attribute with values @(YES), @(NO), @(YES), would the first section receive one row (because NO corresponds to 0) and the second section receive two...

Avoid jump in `UITableView` during background update from `NSFetchedResultsController`

ios,uitableview,swift,core-data,nsfetchedresultscontrolle
I have a UITableView used with NSFetchedResultsController right from the book. The CoreData objects are updated by a background process so every update automatically triggers an update of the FetchedResult and UITableView. Pulling down the UITableView during these updates causes a disturbing jump back to the top followed by a...

Core Data: How to fetch Entities based on an attribute of a related entity

ios,core-data,nspredicate,nsfetchedresultscontrolle,nsfetchrequest
This is what the pertinent part of my object graph looks like: [Anime] <->> [AnimeName @string @type] So an Anime object has many AnimeName objects that contain a string and the type of name they are. Now to implement a "Search by Name" feature, I would need a predicate that...

NSFetchedResultsController crashing when creating it, objc_exception_throw

ios,objective-c,core-data,nsfetchedresultscontrolle
I am receiving a objc_exception_throw when creating my NSFetchedResultsController. I am relatively new to iOS programming so I am still getting the hang of debugging iOS crashes. let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate lazy var parentContext: NSManagedObjectContext? = { if let managedObjectContext = self.appDelegate.managedObjectContext { return managedObjectContext } else {...

How do I access the attribute of a one to many relationship and pass to another tableview?

uitableview,core-data,nsfetchedresultscontrolle,nsmanagedobject
So I have two entities in CoreData (A and B). A has many Bs and B can only belong to one A. I have managed to display A on a tableview and when I tap a cell, it should segue to another tableview controller that displays the list of Bs....

Slow UISearchDisplayController with Core Data

ios,iphone,core-data,nsfetchedresultscontrolle,uisearchdisplaycontroller
I have a TableViewController displaying like 40 000 rows from Core Data with NSFetchedResultsController. I implemented a live search with a UISearchDisplayController (support for IOS 7). It's working but typing on the keyboard when searching is very slow... I'd really appreciate if someone could point me to the right direction...

Disable animations produced by NSFetchedResultsController on batch update deleting

ios,animation,nsfetchedresultscontrolle
I'm currently using NSFetchedResultsController to display content in a UITableView instance. At some point, I do a batch delete followed by a batch insert in Core Data. As a result, the NSFetchedResultsControllerDelegate proceed the insertion and deletion one by one. This gives a strange look to the GUI where you...

NSFetchedResultsController swift sections

ios,swift,core-data,nsfetchedresultscontrolle,sections
I have a table view that takes data from a CoreData entity with 3 fields. firstName: String, lastName: String and done:NSNumber (which is a UISwitch that can be turned ON or OFF). I want to populate the table with the first and last names but first section is with names...

NSFetchedResultsController sort negative string values

ios,sorting,nsfetchedresultscontrolle,nssortdescriptor
I have NSFetchedResultsController which returns objects with index attribute, index attribute is a NSString and for example I have these values for index attribute: -1, -3, 1, 0, -2, 3 I need to define NSSortDescriptor which will sort these objects like this based on index attribute value: -3, -2, -1,...

Using UICollectionView with CoreData and NSFetchedResultsController

ios,swift,uicollectionview,nsfetchedresultscontrolle,uicollectionviewdelegate
I recently started another project exploring Swift a little bit. I want to implement a Collection View using a NSFetchedResultsController to get the data out of my CoreData database. I wanted to use the example from https://github.com/AshFurrow/UICollectionView-NSFetchedResultsController and implement something similar in Swift. I don't need any of the move...

Fetched Results Controller returns Number of Sections = 0

ios,objective-c,core-data,nsfetchedresultscontrolle,uimanageddocument
I am using a NSFetchedResultsController inside a UITableViewController. Unfortunately, [self.fetchedResultsController.sections count] returns a value of 0 which is incorrect. It should return 1 section: - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { NSInteger numberOfSections = [self.fetchedResultsController.sections count]; return numberOfSections; } This is the code I am using to instantiate the NSFetchedResultsController and load the...

Adding Missing Dates in NSArray

ios,objective-c,arrays,nsarray,nsfetchedresultscontrolle
I have an array that has the past 5 days. It is built like this: ( "2015-01-27", "2015-01-26", "2015-01-25", "2015-01-24", "2015-01-23", ) I have a second NSArray from a FetchRequest ( { daySectionIdentifier = "2015-01-24"; sumValue = 2500; }, { daySectionIdentifier = "2015-01-25"; sumValue = 1487; }, { daySectionIdentifier =...

two arrays from NSFetchedResultsController swift

ios,swift,core-data,nsfetchedresultscontrolle
I have a table that is populated using data from CoreData and NSFetchedResultsController. It populates two sections using one attribute having a boolean value. But I want to have the data in each section into two arrays for further processing. Is there a way to save the data in the...

NSFetchedResultsController does not reload data on request

ios,objective-c,uitableview,uiscrollview,nsfetchedresultscontrolle
Hopefully someone can explain to me why my NSFetchedResultsController only fetches data once. I have created a singleton with a NSFetchedResultsController method in it. My app has a UITabBarController and in one of the tabs is an UINavigationController. Inside this UINavigationController I have setup a UIScrollView with 3 tableviews, all...

How to pass NSManagedObject to NSPredicate and how to save one-to-many Entities

ios,core-data,nsfetchedresultscontrolle
I have a simple iOS8 Core Data application that lists information about a patient in a Master Detail structure. Xcode 6.3.1 That piece of the app works fine - a tableView of Patients with details on each Patient in a second view controller. Core Data has just two entities -...

Can NSFetchedResultsController work with NSDictionaryResultType?

ios,cocoa,core-data,nsfetchedresultscontrolle
I use Core Data to store shops as Entity Shop and on every shop I have an Attribute city, I want to group the shops by city and present a UITableView with all the cities. I use NSFetchedResultsController to fetch the data and refresh the UITableView and since I want...

How to write into the CoreData entity at the same index in different view controller (also swift files)

core-data,nsfetchedresultscontrolle,nsmanagedobject
I have created core data using 'NSFetchedResultController' and 'managedObjectContext' in a table view. But in the later view controller, after gathering accelerometer data and conduct calculation, I will get some results that I also want to store in the same row index with the core data I created before. How...

NSFetchedResultsController consistent delay in updating UITableView cell; insert works instantaneously

ios,objective-c,uitableview,core-data,nsfetchedresultscontrolle
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 data) and store it as a new core data Entity....

`NSFetchedResultsController` fetched data changes with and without save when using predicate

objective-c,core-data,nsfetchedresultscontrolle
NSFetchedResultsCotroller behaves strangely when using predicate. The following code prints the output: Rows - 0 But when I comment out [self saveContext] (the first one) the output becomes: Rows - 1 Removing the predicate (query.predicate) fixes things and the output is always: Rows - 1 I suspect it has something...

UICollectionViewController halts scrolling when inserting new cells

swift,uicollectionview,restkit,nsfetchedresultscontrolle
I have a UICollectionView that is endlessly scrolling. As the user scrolls, the controller makes API requests for new pages, usually loading the next page before the user gets to the bottom of her feed. However, when the UIViewController updates with new data via a fetchedResultsController, the scrolling stops, even...

Method for moving rows with NSFetchedResultsController and its delegate not working

ios,swift,core-data,tableview,nsfetchedresultscontrolle
I've been trying to follow this tutorial for rearranging rows in a table view while using NSFetchedResultsController and NSFetchedResultsController delegate, but my project is extremely buggy. What happens is that when I try rearranging a row and drop it, the rows are randomised (probably not randomised, but I can't see...

NSFetchedResultsChangeUpdate - updated object's changedValues dictonary is empty

ios,objective-c,core-data,nsfetchedresultscontrolle,nsmanagedobjectcontext
My tableview cell is quite complex to fully relayout for each NSFetchedResultsChangeUpdate changeType. So I've decided to update it just for specific changes of the changed MO. I thought, that the changedValues of a MO should contain the changed properties. But sometimes it contains them, sometimes it's an empty dictionary....

reset context does not fire fetchResultedController

ios,core-data,nsfetchedresultscontrolle,nsmanagedobjectcontext
I binded a fetchResultedController to a context, that is reset-ed. Before it I have added a record to this context, and didChangeObject was invoked with the .Insert changeType, but after reset I was expect didChangeObject will get called with .Delete changeType, but it does not happened. Any idea how to...

_fetchedResultsController objectAtIndexPath:indexPath freezes app

ios,core-data,nsfetchedresultscontrolle
It takes too much time on [_fetchedResultsController objectAtIndexPath:indexPath], is there any alternative way ? heightForRowAtIndexPath takes too much time on this point. I don't know this is wrong question or not, but please help me to get the proper solution. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { ThreadInfo *info=[_fetchedResultsController objectAtIndexPath:indexPath]; NSString*...