nsfetchedresultscontroller

Indexing results from an NSFetchedResultsController

爷,独闯天下 提交于 2019-12-22 06:16:19
问题 I'm having some issues with a mixed, indexed, searchable results set from an NSFetchedResults controller. I have it set up to store an indexed A-Z first initial for an entity, and then want it to display numeric first initials (i.e. # as the UILocalizedIndexCollation would do). I have already written the code that saves a "firstInitial" attribute of an Artist object as NSString @"#" if the full name started with a number, and I seem to have gotten the code half working in my

NSSortDescriptor not sorting integers correctly

假装没事ソ 提交于 2019-12-22 05:26:21
问题 I'm trying to sort by date then start time. Start time is minutes from midnight. So if the start time is < 100 it will not sort properly. - (NSFetchedResultsController *)fetchedResultsController { if (fetchedResultsController != nil) { return fetchedResultsController; } /* Set up the fetched results controller. */ // Create the fetch request for the entity. NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; // Edit the entity name as appropriate. NSEntityDescription *entity =

NSFetchedResultsController: sort descriptors and sections

霸气de小男生 提交于 2019-12-22 05:08:10
问题 I have a core data model like so... [Country] <--->> [League] <--->> [Match] And I'm using an NSFetchedResultsController to display the Matches into a UITableView . I've done this a million times before but for some reason the sections are going wrong and I can't work out why. I have created the sort descriptors like so... NSSortDescriptor *countrySD = [NSSortDescriptor sortDescriptorWithKey:@"league.country.name" ascending:YES]; NSSortDescriptor *leagueSD = [NSSortDescriptor

NSFetchedResultsController objectAtIndex, objectAtIndexPath, indexPathForObject inconsistencies

﹥>﹥吖頭↗ 提交于 2019-12-22 04:20:11
问题 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: [fetchedResultsController objectAtIndexpath:indexPath] An error occurs after I insert an row (for one of the SearchResult objects) into the corresponding table. The object appears to be inserted into the new table correctly. After I have visually confirmed this, I

Coredata object fault in independent ManagedObjectContext vs changes in persistent store

ぐ巨炮叔叔 提交于 2019-12-22 00:08:24
问题 I have an operation object which creates it's own Managed Object Context. The operation object performs calculation basically to take off load from main thread while main thread concentrates on the UI aspect. This operation object's MOC shares a common persistent store across the application. It sometimes happens such that, while the operation is being performed, the MOC of main thread is notified of changes in backend. So, I try to merge the changes of MOC, where some of the deletions in

Get parent-child array from coredata

蹲街弑〆低调 提交于 2019-12-21 22:45:56
问题 I have a CoreData model that can contain an infinite number of children. And I want to display a list of each object, indented for readability like so Object Object first child first childs children first child children Object second child Object 2 Object also has children MOre children Childs Now I come from a PHP background. and in PHP I would create a simple array which Ill traverse with some functions to build this list but this still seems stupidly hard for me. I got a flat array which

Updating fetchedResultsController for predicate set by UISearchBar

▼魔方 西西 提交于 2019-12-21 20:59:01
问题 Refactored to vanilla UIViewController Rather than having the UITableView toggle between active and inactive UISearchController , I refactored to a vanilla UIViewController with a UISearchBar at the top and a UITableView directly underneath it. What I'm trying to do is toggle the fetchedResultsController between having a predicate which is set by the text in the searchBar and one that grabs everything. I found this answer, which describes a solution to a similar problem in Objective-C and

[ controllerWillChangeContent:]: message sent to deallocated instance

本秂侑毒 提交于 2019-12-21 20:51:02
问题 I am having a problem with my ipad app. I've got a view that is accessed in 2 ways, if i go in one way it works perfectly. If I go in through another though, it crashes when saving the context. I suspect it is something in the parent (orders by customer) -- I get a zombie with the message: [OrdersByCustomer controllerWillChangeContent:]: message sent to deallocated instance 0x10102020 when I run it through intstruments with Zombies I get: # Category Event Type RefCt Timestamp Address Size

How to prevent NSFetchedResultsController from updating tableview when the controller disappears?

[亡魂溺海] 提交于 2019-12-21 16:26:12
问题 I have a UITabbar with multiple controllers in it. One of the controllers is used to add Events to Core Data, while another controller is used to display events as in a UITableView using NSFetchedResultsController . Here's the behaviour that I would like to achieve: Upon disappearing, the UITableView stops updating, and when the user comes back, the entire table view is reloaded. Otherwise, inserting events from the other controller takes longer, as new rows are created in the UITableView ,

NSFetchedResultsController index beyond bounds

痴心易碎 提交于 2019-12-21 13:08:06
问题 I'm using an NSFetchedResultsController to display items in my table view: - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { // Return the number of sections. return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { // Return the number of rows in the section. return [[self.fetchedResultsController fetchedObjects] count]; } // Customize the appearance of table view cells. - (UITableViewCell *)tableView:(UITableView *)tableView