nsfetchedresultscontroller

How to properly trim object graph brought in by NSFetchedResultsController?

孤人 提交于 2019-12-20 05:29:07
问题 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

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

本秂侑毒 提交于 2019-12-20 02:00:14
问题 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

“didChangeSection:” NSfetchedResultsController delegate method not being called

喜你入骨 提交于 2019-12-19 19:13:16
问题 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

Core Data: Keypath “objectID” not found in entity

天大地大妈咪最大 提交于 2019-12-19 13:12:47
问题 I'm using NSFetchedResultsController with a predicate to load a list of Documents in my application. I want to load all the Documents except the currently active one. I am using Rentzsch's MOGenerator to create a _Document class and then I put all my custom code in the Document subclass. _Document generates an objectID property with type DocumentID . In the class that creates the controller, I set the controller's currentDocID property: controller.currentDocID = self.document.objectID; In the

Format sectionNameKeyPath NSFetchedResultsController - Swift

一笑奈何 提交于 2019-12-19 10:09:06
问题 I am attempting to format my sectionNameKeyPath for my core data fetch using a stored NSDate attribute. It is fully working and pulling/sorting the records into sections based on the NSDate but I am not sure how to format it to display it by dd-mm-yyyy. I know how to format NSDate using: let date = NSDate(timeIntervalSince1970:myTimeInterval) let dateFormatter = NSDateFormatter() dateFormatter.dateFormat = "dd-MM-yyyy" My current fetch request using core data attribute sectionDate as the

NSSortDescriptor issue

守給你的承諾、 提交于 2019-12-19 09:19:06
问题 I am making a contact book App where I am fetching names from AddressBook and stored them in Core data and displayed the names on a table using NSFetchedResultsController.However the first index and section that comes up is # followed by the alphabets. But I want to do it like it is in native contact app i.e. # index should come at last. I used the following NSortDescriptor : sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"fullName" ascending:YES ]; here "fullName" is the key in core

NSSortDescriptor with arbitrary sorting

萝らか妹 提交于 2019-12-19 09:04:17
问题 I can't wrap my head around how to do arbitrary sorting with a NSSortDescriptor. I want to do something like this: NSArray *sortAlgorithm = [NSArray arrayWithObjects:@"@", @"#", @"!", @"&", @"r", @"a", nil]; NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"name" ascending:YES comparator: ^(id obj1, id obj2) { NSComparisonResult comparisonResult; //Some code that uses sortAlgorithm. return comparisonResult; } ]; This would sort the objects by the key name so that any

UITableView unexpectedly bounces with beginUpdates()/endUpdates()/performBatchUpdates()

烈酒焚心 提交于 2019-12-19 08:33:16
问题 I have a pretty straight forward UITableViewController / NSFetchedResultsController case here. It's from Xcode Master-Detail App sample code, So easy to reproduce. I have a CoreData Model with 1 Entity with 1 String Attribute. It's displayed in a UITableViewController . I use .subtitle system cell type. By selecting a row, I simply update the String Attribute. So my problem is, when I add just enough rows for the tableview to scroll (10-11 rows on a iPhone 5s with navbar), and I scroll down,

Does NSFetchedResultsController Observe All Changes to Persistent Store?

╄→尐↘猪︶ㄣ 提交于 2019-12-19 06:16:14
问题 My program does work like link below: Update results of NSFetchedResultsController without a new fetch show result of NSFetchedResultsController to UITableView get new object from web service and store it to core data (in same view controller, with RestKit) update table view with notification of NSFetchedResultsController delegate The implementation of NSFetchedResultsControllerDelegate is copied from Apple's Core Data project and my predicated is: [NSPredicate predicateWithFormat:@"isMyTest

NSFetchedResultsController calls didChangeObject delete instead of update

二次信任 提交于 2019-12-18 18:46:33
问题 This is the code, I save the model via Magical Record: MagicalRecord.saveWithBlock({ (localContext) -> Void in var localNotification = CDNotification.MR_findFirstByAttribute("notificationID", withValue: notification.notificationID, inContext: localContext) as CDNotification localNotification.readNumber = NSNumber(bool: true) }) Delete is called instead of update after the code above is called: func controller(controller: NSFetchedResultsController, didChangeObject object: AnyObject,