nsfetchedresultscontroller

Transient sectionNameKeyPath & NSSortDescriptor NSFetchedResultsController

与世无争的帅哥 提交于 2019-12-03 15:41:18
问题 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 use a derived transient attribute calculated on the fly based on other attributes in the relative object. Unfortunately you cannot pass a derived value as a sort descriptor used by a fetch request. This is because a fetch relies on already having data it

iPhone: NSFetchedResultsController with delegate and data update from a separate thread

∥☆過路亽.° 提交于 2019-12-03 13:39:24
问题 First of all, sorry for the too long question. I know that there are few questions here that discuss similar issues but none of these talks about NSFetchedResultsController with delegate together with update in separate thread. And none of the solutions has helped me. These are the existing questions: NSFetchedResultsController: using of NSManagedObjectContext during update brings to crash Determining which core Data attribute/property change triggered a NSFetchedResultsController update Core

NSFetchedResultsController doesn't see new inserts / removes fetched values after update

蓝咒 提交于 2019-12-03 13:15:46
After reading dozens of similar questions, I'd like to start with this statement: "I DID set the delegate of the NSFetchedResultsController, it didn't work.". So I have a simple TableViewController whose cells are filled with NSFetchedResultsController. Here's the FRC init code: @property (strong, nonatomic) NSFetchedResultsController *frc; ... - (NSFetchedResultsController *)frc { if (!_frc) { NSError *error = nil; NSFetchRequest *request = [[NSFetchRequest alloc] initWithEntityName:e_product]; request.sortDescriptors = [NSArray arrayWithObjects: [NSSortDescriptor sortDescriptorWithKey:@

Saving Single CoreData Entity (Not the Whole Context) While Keeping NSFetchedResultController Functionality

邮差的信 提交于 2019-12-03 12:38:55
Phew, sorry for the long title. I have a single Managed Object Context where I am storing songs derived from two different locations. I get some of the songs from the persistent storage on the phone (using Core Data), and I pull some of the songs from an online database. Both of the songs are of the same MananagedObject subclass. I would like both of these songs to be in a single context because I would like them both to show up on a table view connected with an NSFetchedResultsController. The problem occurs when I would like to save one of the songs. I don't want to save all of the songs that

Core data: The fetched object at index x has an out of order section name 'xxxxxx. Objects must be sorted by section name

白昼怎懂夜的黑 提交于 2019-12-03 11:00:32
问题 I know I'm not the first to ask this question but I'm really stumped.. Basically I have a screen with two buttons. Each button loads data into a tableview below based on a date. On the first load of the first tableview (the left button is selected by default) everything displays fine. If I click on the right button and I get a blank tableview, and I get the error The fetched object at index x has an out of order section name 'xxxxxx. Objects must be sorted by section name. Switching back to

FetchedResultsController Swift 3 API Misuse: Attempt to serialize store access on non-owning coordinator

梦想与她 提交于 2019-12-03 10:54:22
I'm attempting to use a fetchedResultsController to handle the results in my UITable. It works initially when the program starts up. Then when I switch back to the inventory tab where my table is (for the viewToAppear again), this is when it crashes. I'm getting a runtime crash error in my viewWillAppear() method of the window which has the table. In particular it crashes on the Inventory+CoredataProperties.swift file on this line let characters = name!.characters.map { String($0) } , but I suspect the error is somewhere else as this works initially so why not now on the 2nd reload? Here is

Core Data Sort By Date With FetchedResultsController into sections

寵の児 提交于 2019-12-03 10:01:10
问题 I currently have a class which has a date object in it. This date object has both time and day in it. All this information gets loaded into a UITableViewCell via a NSFetchedResultsController . I need to sort the dates into sections where each section is the date without the Time. I also need each section to be sorted in itself by time. Here is what my current _fetchedResultsController looks like: [self.managedObjectContext lock]; NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];

A-Z Index from NSFetchedResultsController with individual section headers within each letter?

橙三吉。 提交于 2019-12-03 09:32:38
问题 I have an NSFetchedResultsController which fetches data from a Core Data structure, a list of albums. It's currently sorted by the artist, so all the A's, B's, etc. I want to add an index so the user can quickly jump to each letter, and I'm using the code below to do it. The issue is that the section headers are now "A", "B", "C", etc., too, meaning I've lost the section headers in alphabetical order with each individual artist on it ("Adele", "America", "Beatles, The", etc.) I'd like the

iPhone contacts app styled indexed table view implementation

点点圈 提交于 2019-12-03 09:15:38
My Requirement: I have this straight forward requirement of listing names of people in alphabetical order in a Indexed table view with index titles being the starting letter of alphabets (additionally a search icon at the top and # to display misc values which start with a number and other special characters). What I have done so far: 1. I am using core data for storage and "last_name" is modelled as a String property in the Contacts entity 2.I am using a NSFetchedResultsController to display the sorted indexed table view. Issues accomplishing my requirement: 1. First up, I couldn't get the

Sectioning TableView and rows with Core Data Swift

◇◆丶佛笑我妖孽 提交于 2019-12-03 08:52:22
I have two tables in sqlite: The code was generated by XCode Generation: class Event: NSManagedObject { @NSManaged var startDate: NSDate @NSManaged var details: EventDetail //i think this property shoud be var details Array<EventDetail> am i correct? } class EventDetail: NSManagedObject { @NSManaged var title: String @NSManaged var location: String @NSManaged var note: String @NSManaged var endDate: NSDate @NSManaged var event: NSManagedObject } I want to put the events in section and the eventDetails in rows . I created the method to load events: var eventList : Array<AnyObject> = [] func