nsfetchedresultscontroller

How to add additional objects with fetch result controller fetched objects list?

家住魔仙堡 提交于 2019-12-25 19:57:37
问题 I have an entity called “Event“ which has s start and end date properties. I have to show the list of events by grouping them by date in UI. I am using NSFetchedResultsController to fetch and list the events. Let's assume an event has start date today and end date tomorrow, here I need to show this event on two different dates in UI but I will have only one entry in the database. I really don’t want to create multiple entries for an event and also I wish to use fetch result controller as it

Core Date Concept: NSFetchedResultsController vs. NSManagedObject objectsWithFetchRequest

寵の児 提交于 2019-12-25 14:24:37
问题 When do I use a NSFetchedResultsController in comparsion to the objectsWithFetchRequest method in NSManagedObject? Are there typical scenarios? 回答1: objectsWithFetchRequest: (or executeFetchRequest:error: ) just executes a fetch request and returns the result set. A NSFetchedResultsController executes a fetch request and then monitors changes to the data store (or more precisely, changes to the managed object context). If objects are added/deleted/modified that cause the result set of the

filtering NSFetchedResultController via searchBar without loading base pauses?

泪湿孤枕 提交于 2019-12-25 08:18:39
问题 i try to create search in big Core Data base (32 thousand objects) but when i added some text to the UISearchBar i have some lags (because my base is updating with new search Predicate) how to fix this? how can i update my base in background thread? fetchedResultController code lazy var context: NSManagedObjectContext = { let appDelegate = (UIApplication.shared.delegate as? AppDelegate) let context = appDelegate!.managedObjectContext return context//appDelegate!.managedObjectContext }() lazy

Why is indexPath for section 1 of a tableview starting with a value of [1,0]

ε祈祈猫儿з 提交于 2019-12-25 07:49:00
问题 I have a tableView and it's split into 2 sections. func numberOfSections(in tableView: UITableView) -> Int { return 2 } Each section has it's own FetchResultController (FRC). This is my CellForRoatAt function func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "personCell", for: indexPath) as! PersonTableViewCell switch(indexPath.section) { case 0: print("this is section 0") let person =

Core Data and Table Views

▼魔方 西西 提交于 2019-12-25 05:22:34
问题 Scenario : I have an expense tracking iOS Application and I am storing expenses from a expense detail view controller into a table view that shows the list of expenses along with the category and amount. On the top of the tableview, is a UIView with CALENDAR button, a UILabel text showing the date (for example: Oct 23, 2012 (Sun)) and 2 more buttons on the side. The pressing of the calendar button opens up a custom calendar with the current date and the two buttons are for decrementing and

Appending data to NSFetchedResultsController during find or create loop

你离开我真会死。 提交于 2019-12-25 04:44:41
问题 I have a table view that is managed by an NSFetchedResultsController. I am having an issue with a find-or-create operation, however. When the user hits the bottom of my table view, I am querying my server for another batch of content. If it doesn't exist in the local cache, we create it and store it. If it does exist, however, I want to append that data to the fetched results controller and display it. I can't quite figure that part out. Here's what I'm doing thus far: The

NSFetchedResultsController notify for changes in another entity (Best practice)

安稳与你 提交于 2019-12-25 03:27:28
问题 I have two entities (MetaData and Prices) with a many-to-many relationship. The entity MetaData has an attribute dataIsInvalid to invalidate all related prices in the entity Price . I'm using a NSFetchedResultsController for MetaData and one FRC for Price . The predicate for FRC Price is @"ANY metaData.dataIsInvalid == 0" . Of course, if I change the dataIsInvalid attribute in MetaData , the controllerDidChangeContent method from FRC Price is not called, but the method in FRC MetaData . So I

Core data fetch predicate for NSDate

孤街醉人 提交于 2019-12-25 03:17:09
问题 I have entity with two NSDate properties: @property NSDate *startTime; @property NSDate *endTime; I use it for creating the point events and the duration events. So, for the point events endTime can be equal to nil. And i want to fetch all entities with restriction: startTime >= minDate && endTime <= maxDate But NSPredicate like: NSDate *startTime = [[NSUserDefaults standardUserDefaults] objectForKey:@"firstBound"]; NSDate *endTime = [[NSUserDefaults standardUserDefaults] objectForKey:@

NSFetchedResultsController initWithFetchRequest throws EXE-BAD-ACCESS exception

爷,独闯天下 提交于 2019-12-24 23:52:29
问题 I have an NSFetchedResultsController inside a subclass of UITableViewController inside a UINavigationController . When I run the app, everything works perfectly the first three times I access the view (going to it, then clicking 'Back', then going to it again), but on the fourth (always) it crashes with the following: -[NSEntityDescription subentitiesByName]: message sent to deallocated instance 0x8b09c80 Any help would be much appreciated. Here is my getter for the results controller: -

iOS: Saving managed object context takes over 1 second after a while

随声附和 提交于 2019-12-24 14:40:26
问题 Strange problem, and strangely only since yesterday. I have a fetched results controller in which you can reorder the rows without any problem. After a fresh start of the app, everything works fine and fast. However if you change from this tab bar to another tab bar and edit some random textfield (which isn't even linked to core data and doesn't trigger any save), the reordering is very slow. And I was able to narrow it down only to the save context. But now I have no clue where to look