nsfetchedresultscontroller

How to properly trim object graph brought in by NSFetchedResultsController?

旧街凉风 提交于 2019-12-02 04:58:11
Without reference cycles NSFetchedResultsController can turn its managed objects into fault properly when they are not needed. But with reference cycles, it not, so I have to re-fault those objects myself. However, manually re-faulting objects managed by NSFetchedResultsController is dangerous . So I want know what you Core Data experts think is the best way to trim object graph brought in by NSFetchedResultsController . Thanks. Update: I believe normally FRC should be able to re-fault objects, even with reference cycles. I have the impression that it is not because of an old bug that I

NSPredicate in NSFetchedResultsController doesn't use Category's getter

左心房为你撑大大i 提交于 2019-12-01 22:12:38
问题 I have an attribute with an int_32 property called seconds. In a category, I restate the property as readonly and override the getter to create it from other properties. The issue is when I use [NSPredicate predicateWithFormat:@"SELF.seconds > %i"]; The predicate does not work because the getter is not called by the predicate. It is called in my other code just fine, just not in the predicate. Anyone know why this would happen or how to get around this problem? (besides recreating

How can I solve NSInternalInconsistencyException', reason: '+entityForName: fail report

此生再无相见时 提交于 2019-12-01 21:09:32
My code looks like that: NSManagedObjectContext *context = [self.fetchedResultsController managedObjectContext]; NSEntityDescription *entity = [[self.fetchedResultsController fetchRequest] entity]; NSManagedObject *newManagedObject = [NSEntityDescription insertNewObjectForEntityForName:[entity name] inManagedObjectContext:context]; // If appropriate, configure the new managed object. [newManagedObject setValue:[NSDate date] forKey:@"date"]; // Save the context. NSError *error = nil; if (![context save:&error]) { NSLog(@"Unresolved error %@, %@", error, [error userInfo]); abort(); } in .h

NSPredicate in NSFetchedResultsController doesn't use Category's getter

為{幸葍}努か 提交于 2019-12-01 20:56:54
I have an attribute with an int_32 property called seconds. In a category, I restate the property as readonly and override the getter to create it from other properties. The issue is when I use [NSPredicate predicateWithFormat:@"SELF.seconds > %i"]; The predicate does not work because the getter is not called by the predicate. It is called in my other code just fine, just not in the predicate. Anyone know why this would happen or how to get around this problem? (besides recreating NSFetchedResultsController). The predicate is converted into SQL and run on the store. It doesn't run any of your

Show distinct results in fetch request, group by an attribute and calculate the total for that attribute

一世执手 提交于 2019-12-01 20:41:25
Scenario: I have an expense tracking iOS Application and I have a view controller called "DashBoardViewController" (table view controller - with FRC) which would basically categorize my expenses/incomes for a given week, a month, or year and display it as the section header title for example : (Oct 1- Oct 7, 2012) and it shows expenses/incomes ROWS and related stuff according to that particular week or month or year. My Question: What I want to accomplish is : Suppose I save 3 new expenses with SAME category named "Auto" on three different dates(11 nov, 14 nov, 16 nov, 2012 respectively). In

“didChangeSection:” NSfetchedResultsController delegate method not being called

痴心易碎 提交于 2019-12-01 18:25:10
I have a standard split view controller, with a detail view and a table view. Pressing a button in the detail view can cause the an object to change its placement in the table view's ordering. This works fine, as long as the resulting ordering change doesn't result in a section being added or removed. I.e. an object can change it's ordering in a section or switch from one section to another. Those ordering changes work correctly without problems. But, if the object tries to move to a section that doesn't exist yet, or is the last object to leave a section (therefore requiring the section its

Getting NSFetchedResultsController, NSSortDescription and sectionNameForKeyPath to work together

六月ゝ 毕业季﹏ 提交于 2019-12-01 16:49:37
I'm currently working on an App that has a couple of Entities and relationships as illustrated below: Item <<--> Category . I am currently fetching Item instances and displaying them in sections using the item's category.name . In this case I can use a sort descriptor to sort the categories by name, which is pretty straightforward and working fine (relevant code below): -(NSFetchedResultsController*)fetchedResultsController { if (fetchedResultsController_ != nil) return fetchedResultsController_; NSManagedObjectContext *moc = [order_ managedObjectContext]; NSFetchRequest *fetchRequest = [

Getting NSFetchedResultsController, NSSortDescription and sectionNameForKeyPath to work together

Deadly 提交于 2019-12-01 15:54:46
问题 I'm currently working on an App that has a couple of Entities and relationships as illustrated below: Item <<--> Category . I am currently fetching Item instances and displaying them in sections using the item's category.name . In this case I can use a sort descriptor to sort the categories by name, which is pretty straightforward and working fine (relevant code below): -(NSFetchedResultsController*)fetchedResultsController { if (fetchedResultsController_ != nil) return

Custom Section Name Crashing NSFetchedResultsController

坚强是说给别人听的谎言 提交于 2019-12-01 11:24:11
I have a managed object with a dueDate attribute. Instead of displaying using some ugly date string as the section headers of my UITableView I created a transient attribute called "category" and defined it like so: - (NSString*)category { [self willAccessValueForKey:@"category"]; NSString* categoryName; if ([self isOverdue]) { categoryName = @"Overdue"; } else if ([self.finishedDate != nil]) { categoryName = @"Done"; } else { categoryName = @"In Progress"; } [self didAccessValueForKey:@"category"]; return categoryName; } Here is the NSFetchedResultsController set up: NSFetchRequest

NSFetchedResultsController updating with wrong update type

∥☆過路亽.° 提交于 2019-12-01 07:44:09
问题 Please see the comments before blindly voting this as a duplicate. It isn't a duplicate question. First - I'm using MagicalRecord for core data. Second - My UICollectionView is populated with an NSFetchedResultsController . The NSPredicate for the NSFetchedResultsController is ... NSPredicate *eventPredicate = [NSPredicate predicateWithFormat:@"event = %@", self.event]; NSPredicate *deletedPredicate = [NSPredicate predicateWithFormat:@"deleted == NO"]; NSPredicate *compoundPredicate =