nsfetchedresultscontroller

NSFetchedResultsController multiple entities for UITableView

泪湿孤枕 提交于 2019-12-06 04:17:37
问题 I have two entities one called Post and one called User. Post<<---->User is the relationship in core data. I am using a NSFetchedResultsController to fetch all Post records in my core data stack and then displaying them in a UITableView. Each cell has an image and that image corresponds to a User.profilePicture. Upon initializing I do not download the profile picture from the server, I only download when it scrolls past that cell (lazy load). Once I download it I save the downloaded image to

Using NSSortDescriptor to keep 'nil' values at the bottom of a list

点点圈 提交于 2019-12-06 03:34:49
I'm working on sorting NSFetchedResultController data. I need to sort data by their first name. However, there are some entries with no first name. I need the "no first name" objects to appear the bottom of the list, rather than the top. With the current code, when I sort the list by first name, the "no first name" cells are placed at the top. NSFetchRequest *request = [NSFetchRequest fetchRequestWithEntityName:@"Contacts"]; request.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"firstName" ascending:YES]]; _FRC = [[NSFetchedResultsController alloc] initWithFetchRequest:request

NSFetchedResultsController fetch request - updating predicate and UITableView

半城伤御伤魂 提交于 2019-12-06 03:16:03
In my iPhone Core Data app I have it configured in a master-detail view setup. The master view is a UITableView that lists objects of the List entity. The List entity has a to-many relationship with the Task entity (called "tasks"), and the Task entity has an inverse to-one relationship with List called "list". When a List object is selected in the master view, I want the detail view (another UITableView) to list the Task objects that correspond to that List object. What I've done so far is this: In the detail view controller I've declared a property for a List object: @property (nonatomic,

Core Data sectionNameKeyPath with Relationship Attribute Performance Issue

我是研究僧i 提交于 2019-12-06 02:53:41
问题 I have a Core Data Model with three entities: Person , Group , Photo with relationships between them as follows: Person <<-----------> Group (one to many relationship) Person <-------------> Photo (one to one) When I perform a fetch using the NSFetchedResultsController in a UITableView , I want to group in sections the Person objects using the Group 's entity name attribute. For that, I use sectionNameKeyPath:@"group.name" . The problem is that when I'm using the attribute from the Group

NSFetchedResultsChangeDelete not being triggered

南笙酒味 提交于 2019-12-06 02:12:18
Has anyone run into this before? When I choose to delete a row from my tableView (populated by an FRC), the app doesn't crash or hang. It doesn't do anything. The delete button stays selected and if I click elsewhere on the simulator, the delete button deselects and disappears, but the cell is never removed form the UI. I'm sure there is a dumb oversight I am making here, but I can't spot it. Below are the relevant portions of my code. I have my UITableViewController interface declared as such: #import <UIKit/UIKit.h> #import "RubricAppDelegate.h" @interface ClassList : UITableViewController

UITableView unexpectedly bounces with beginUpdates()/endUpdates()/performBatchUpdates() using NSFetchedResultsController and CoreData

偶尔善良 提交于 2019-12-05 22:33:50
UITableView unexpectedly bounces with beginUpdates() / endUpdates() / performBatchUpdates() using NSFetchedResultsController and CoreData when the number of rows fill the view. It's pretty simple to reproduce. - Create a new project from the Master-Detail App Template (with CoreData). - In the storyboard, remove the "showDetail" segue. (we don't need the detail view) - In MasterViewController, replace segue func prepare() with : override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { let event = fetchedResultsController.object(at: indexPath) let timestamp =

How to get DateSectionTitles using FetchedResultsController in Swift 4

六眼飞鱼酱① 提交于 2019-12-05 21:35:40
I am using FRC and I want to create sections that groups data according to date (DD MMMM)! Each task has a date and i am using that date and formatting it for the section header titles. I am using Apple's sample code that they have provided in Objective C and converted it in to swift. Here is the code: import UIKit import CoreData class completedNotes: NSManagedObject { @NSManaged var cNote: String @NSManaged var cPriorityColor: UIColor @NSManaged var cDate: Date } extension completedNotes { var sectionIdentifier : String? { // Create and cache the section identifier on demand. self

CoreData performFetch in viewDidLoad not working

丶灬走出姿态 提交于 2019-12-05 21:01:33
When my main view controller is loaded and it calls viewDidLoad I am performing a fetch request and retiring an array or my core data objects: + (NSArray *)getData { // Fetch Data NSError *error = nil; if (![[[AppDelegate instance] fetchedResultsController] performFetch:&error]) { // Update to handle the error appropriately. NSLog(@"Unresolved error %@, %@", error, [error userInfo]); abort(); } NSArray *items = [[AppDelegate instance].fetchedResultsController fetchedObjects]; return items; }//end For some reason, this returns an empty array when called from viewDidLoad . If I call the same

Fixing predicated NSFetchedResultsController/NSFetchRequest performance with SQLite backend?

删除回忆录丶 提交于 2019-12-05 20:33:02
I have a series of NSFetchedResultsControllers powering some table views, and their performance on device was abysmal, on the order of seconds. Since it all runs on main thread, it's blocking my app at startup, which is not great. I investigated and turns out the predicate is the problem: NSPredicate *somePredicate = [NSPredicate predicateWithFormat:@"ANY somethings == %@", something]; [fetchRequest setPredicate:somePredicate]; I.e the fetch entity, call it "things", has a many-to-many relation with entity "something". This predicate is a filter that limits the results to only things that have

coredata error because sectionNameKeyPath or grouping data at NSFetchedResultsController

拥有回忆 提交于 2019-12-05 17:33:46
2011-12-28 10:52:13.633 BadgerNew[663:707] CoreData: error: (NSFetchedResultsController) object <Business: 0x628c8e0> (entity: Business; id: 0x628c870 <x-coredata://8D661026-BBFA-4C41-B434-167800D925DD/Business/p88> ; data: { Aliases = "<relationship fault: 0x6219950 'Aliases'>"; Bookmark = 0; Building = nil; City = "0x56531a0 <x-coredata://8D661026-BBFA-4C41-B434-167800D925DD/City/p1>"; Distance = "104.6926812925746"; Districts = ( "0x63bcb30 <x-coredata://8D661026-BBFA-4C41-B434-167800D925DD/District/p1>" ); Email = nil; ID = 74318; Images = "<relationship fault: 0x621a130 'Images'>";