nsfetchedresultscontroller

Serious Application Error in Core Data with fetchedResultsContainer

霸气de小男生 提交于 2019-12-21 07:00:06
问题 I get the following error when trying to add a record: Serious application error. Exception was caught during Core Data change processing. This is usually a bug within an observer of NSManagedObjectContextObjectsDidChangeNotification. The index 0 is invalid with userInfo (null) And that's it. I put breakpoints into all the fetchedResultsContainer delegate methods I have implemented, but nothing breaks. I tracked it down to: NSFetchedResultsController *aFetchedResultsController = [

Serious Application Error in Core Data with fetchedResultsContainer

喜欢而已 提交于 2019-12-21 07:00:01
问题 I get the following error when trying to add a record: Serious application error. Exception was caught during Core Data change processing. This is usually a bug within an observer of NSManagedObjectContextObjectsDidChangeNotification. The index 0 is invalid with userInfo (null) And that's it. I put breakpoints into all the fetchedResultsContainer delegate methods I have implemented, but nothing breaks. I tracked it down to: NSFetchedResultsController *aFetchedResultsController = [

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

不想你离开。 提交于 2019-12-21 04:06:43
问题 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.

NSFetchedResultsController titleForHeaderInSection with formatted NSDate

白昼怎懂夜的黑 提交于 2019-12-21 02:47:40
问题 In my Core Data app I am using a FetchedResultsController. Usually to set titles for headers in a UITableView you would implement the following method like so: - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { id <NSFetchedResultsSectionInfo> sectionInfo = [[<#Fetched results controller#> sections] objectAtIndex:section]; return [sectionInfo name]; } where [sectionInfo name] returns a NSString. my sectionKeyPath is based on an NSDate and this all

How to deal with many to many relationships with NSFetchedResultsController?

半城伤御伤魂 提交于 2019-12-21 02:28:16
问题 OK so I have two entities in my data model (let's say entityA and entityB), both of these entities have a to-many relationship to each other. I have setup a NSFetchedResultsController to fetch a bunch of entityA. Now I'm trying to have the section names for the tableview be the title of entityB. sectionNameKeyPath:@"entityB.title" Now this causes a problem, where by the section name returned from that relationship appears to be ({title1}) or ({title1,title2...titleN}) obviously depending on

iOS crash 'NSInternalInconsistencyException', reason: 'statement is still active' Core Data cache related?

丶灬走出姿态 提交于 2019-12-20 17:37:53
问题 Very occasionally seeing these pop up in crash reports on screens using NSFetchedResultsController , and not sure how to address them. I don't believe I'm using threading anywhere, unless NSFetchedResults is using them internally. 'NSInternalInconsistencyException', reason: 'statement is still active' is the full explanation I get. Two recent stack traces: 0 CoreFoundation 0x37a368bf __exceptionPreprocess + 163 1 libobjc.A.dylib 0x3151c1e5 objc_exception_throw + 33 2 CoreData 0x340b2ea5 -

NSPredicate: Fetch one of each kind

本秂侑毒 提交于 2019-12-20 09:53:15
问题 I want to create an NSFetchRequest for objects like this: The Object is Car which has an attribute color . I have four cars: car1.color = red car2.color = red car3.color = blue car4.color = green I want to create an NSPredicate that selects only one car for each color(it doesn't matter which car it selects. How can I achieve this? In fact I'm looking for something similar like a DISTINCT in SQL 回答1: Core Data does support fetching distinct values. Apple even provides sample code here: http:/

Core Data viewContext not receiving updates from newBackgroundContext() with NSFetchedResultsController

安稳与你 提交于 2019-12-20 08:35:53
问题 In my application, I have a NSFetchedResultsController to load Core Data objects in a UITableView. The fetch request associated with this FRC uses the new viewContext property available for the NSPersistentContainer (iOS10). When I select a cell, I pass the Core Data object to a new ViewController. This new VC still uses the viewContext. From this ViewController, I can update the Core Data object from ViewControllers presented modally. To do so, I use newBackgroundContext() for the modal

NSFetchedResultsController attempting to insert nil object

核能气质少年 提交于 2019-12-20 08:35:47
问题 Edit 7: Here's my save method. It's pretty boilerplate. The DEBUG_LOG() macros are only executed if it's a debug build. - (void)saveManagedObjectContext:(NSManagedObjectContext *)moc { if ([moc hasChanges]) { DEBUG_LOG(@"Saving managed object context %@", moc); NSError *error; BOOL success = [moc save:&error]; if (!success || error) { DEBUG_LOG(@"ERROR: Couldn't save to managed object context %@: %@", moc, error.localizedDescription); } DEBUG_LOG(@"Finished saving managed object context %@",

Sections in UITableView not showing properly

巧了我就是萌 提交于 2019-12-20 05:45:27
问题 I have a problem with UITableView sections. I'm using NSFetchedResultsController to populate table and I've provided sectionNameKeyPath: on initialization. Basiclly I have a table view with one section but when user taps on cell it is changing one core data attribute and should create second section. I think I've accomplished this but... When I tap on the first cell it creates new section above (this is how it should be) but when my first tap is on another cell it creates section at the