nsfetchedresultscontroller

NSFetchedResultsController with search

南楼画角 提交于 2019-11-28 16:15:25
What is the best practice to filter the NSFetchedResultsController data? do i need to re-initialize it every time the searchbar's text changes? I am using a UISearchDisplayControllers and i'm implementing: - (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString; Thx. dk. How is Guy's answer code any different from the question? As far as I can guess, the filterContentForSearchText:scope method is called by the shouldReload methods? Anyway, here's some similar code that I added in the CoreDataBooks sample to include

NSFetchedResultsController prepend a row or section

此生再无相见时 提交于 2019-11-28 15:53:03
问题 I have a UITableView populated with a standard NSFetchedResultsController. However I'd like to prepend a row or a section (row preferably but either would works fine really.) The only way I can possibly see doing this right now is to rewrite all the NSIndexPath's manually when dealing with the section/rows dealing with the data from NSFetchedResultsController to trick it into seeing section at index 0 and starting with row at index 0. This however seems like a really bad idea that would

NSFetchedResultsController: Multiple FRCs, Delegate Error when Updating

对着背影说爱祢 提交于 2019-11-28 14:48:17
Objective: Using FRC, sort Section's by startDate , an NSDate attribute, but want Today 's date Section to appear before Upcoming dates Section . I followed Apple's code using a transient property sectionIdentifier . Apple's sample code . and started with this project first: OneFRC I soon realized that this may not be possible with just one FRC (I could be wrong). Next, I decided to take a stab at this with 3 FRCs : ThreeFRC . TableView sections now appears in the Order that I want: Section 0: Today Section 1: Upcoming Section 2: Past However, adding data triggers FRC delegates, and I get the

Core Data Reset [duplicate]

China☆狼群 提交于 2019-11-28 14:21:19
问题 This question already has answers here : Reset a CoreData persistent store (7 answers) Closed 6 years ago . I am working with resetting my data in coreData, below is my code to reset my data in CoreData - (void) resetApplicationModel { __managedObjectContext = nil; __managedObjectModel = nil; __persistentStoreCoordinator = nil; _allPageViewController.controller = nil; NSError *error; NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"abc.sqlite"]; if ([[self

NSFetchedResultsController: delete 1 row crashes the app

柔情痞子 提交于 2019-11-28 09:52:01
问题 Deleting a row from a UITableView fed by an NSFetchedResultsController causes my app to crash. Error is: * Assertion failure in -[UITableView _endCellAnimationsWithContext:], /SourceCache/UIKit/UIKit-2903.23/UITableView.m:1330 * Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of rows in section 0. The number of rows contained in an existing section after the update (1) must be equal to the number of rows contained in that

NSFetchedResultsController doesn't call controllerDidChangeContent: after update to non-fetched NSManagedObject

做~自己de王妃 提交于 2019-11-28 08:27:30
I populate and save: an initial NSManagedObjectContext setup an NSFetchedResultsController with a different NSManagedObjectContext , which filters on a boolean "show" attribute. Finally update "show" on yet another NSManagedObjectContext and save: . I expect that this should cause my NSFetchedResultsController to call NSFetchedResultsControllerDelegate 's controllerDidChangeContent: . I never get that call. NSFetchedResultsController with predicate ignores changes merged from different NSManagedObjectContext 's accepted answer indicates that in addition to controllerDidChangeContent: , I

How to switch UITableView's NSFetchedResultsController (or its predicate) programmatically?

旧城冷巷雨未停 提交于 2019-11-28 06:39:27
I have a UITableView that displays a subset of a large number of entities named "Documents". The subset is defined by another entity "Selection". Selections are named, ordered list of documents. It Works fine, except when I want to change the displayed selection at run time. I get only a blank list. Basically, I need to change the predicate that my NSFetchedResultsController holds so that the new predicate uses the another Selection. I couldn't make it work. My last attempt is to get rid of the NSFetchedResultsController altogether and reallocate it: - (void) displaySelection:(Selection *)aSet

How to prevent from scrolling UITableView up when NSFetchedResultsController add new record?

只愿长相守 提交于 2019-11-28 04:38:09
问题 My UITableView is scrolling up once I add a new comment to CoreData. NSFetchedResultsController knows about it, puts this comment at the bottom of the table, and scroll table to top. Is it normal? My example: Just before I add a comment: Just after I add a comment (not expected behavior): It should be just like this ( after I swipe it by hand manually ): This may be connected with following situation: This is sort descriptor of my NSFetchedResultsController : NSSortDescriptor(key: "createdAt"

Core Data: UITableView with multiple NSFetchedResultControllers

孤者浪人 提交于 2019-11-28 04:23:18
What I want to do is pretty simple. In my UITableViewController, I want to load data from multiple NSFetchedResultControllers (I have multiple entities in my data model) and put data from each one into a different section in the table view. So for example, all the fetched items from the first NSFetchedResultController would go in section 0 in the UITableView, the fetched items from the other one goes into section 1, etc. The Core Data template project doesn't demonstrate how to do this. Everything (mainly the index paths) is coded without taking sections into account (there are no sections in

iOS 9 - “attempt to delete and reload the same index path”

江枫思渺然 提交于 2019-11-28 03:48:28
This is an error: CoreData: error: Serious application error. An exception was caught from the delegate of NSFetchedResultsController during a call to -controllerDidChangeContent:. attempt to delete and reload the same index path ( {length = 2, path = 0 - 0}) with userInfo (null) This is my typical NSFetchedResultsControllerDelegate : func controllerWillChangeContent(controller: NSFetchedResultsController) { tableView.beginUpdates() } func controller(controller: NSFetchedResultsController, didChangeSection sectionInfo: NSFetchedResultsSectionInfo, atIndex sectionIndex: Int, forChangeType type: