nsfetchedresultscontroller

NSFetchedResultsController multiple entities for UITableView

非 Y 不嫁゛ 提交于 2019-12-04 11:20:46
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 the corresponding User.profilePicture in the core data stack. Is there a way for

Issue with setting NSSortDescriptor key in NSFetchResultController

泄露秘密 提交于 2019-12-04 10:59:16
With respect to the above relationship diagram, Earlier, I had a too many relationship between Assignment and Question entity and this is broken to fix a question ordering issue. Now the relationship to Assignment to Question is through a join table AssignmentQuestion. Idea here was to sort the question based on the questionOrderIndex property of the AssignmentQuestion table. I am fetching the assignment questions through a NSFetchResultController. I have written a predicate to fetch the questions accordingly. But since I want the questions to be sorted based questionOrderIndex, my sort key

Core data: executeFetchRequest vs performFetch

夙愿已清 提交于 2019-12-04 10:24:50
问题 I want a thorough list regarding comparison between the two. Things I have known: executeFetchRequest : Message sent to MOC Return an array of managed objects Goal: fetch objects from persistent store to MOC With table view: has nothing to do with table view Frequency: often used in a loop, so could be called many many times performFetch : Message sent to FRC After calling it, use fetchedObjects to return an array of managed objects With table view: FRC is specifically for keeping managed

Using an NSFetchedResultsController without a UITableViewController

孤街醉人 提交于 2019-12-04 10:04:48
I'm running into problems trying to use a NSFetchedResultsController without a corresponding UITableViewController. According to Apples documentation : "NSFetchedResultsController is intended to efficiently manage the results returned from a Core Data fetch request to provide data for a UITableView object." So I first researched whether using the NSFetchedResultsController without a UITableViewController was advisable and encounter this Stackoverflow post where it is concluded that, at least in some circumstances, it's not a bad idea. But now I've encountered an issue where the

Customized sort in NSFetchedResultsController

穿精又带淫゛_ 提交于 2019-12-04 09:37:03
After spending hours, I found that it was not possible to do customized sort in NSFetchedResultsController backed by SQLite from following article. NSFetchedResultsController custom sort not getting called However, I couldn't find actual solution for my problem. Here's what I am trying to do. Background: I have a English dictionary database (just a simple list of words - very large) in CoreData. Words are shown in UITableView using NSFetchedResultsController. UITableView has an associated Search Bar. When an user inputs a string in Search Bar, UITableView shows a list of words filtered. Why do

TableView with two instances of NSFetchedResultsController

本小妞迷上赌 提交于 2019-12-04 08:19:19
问题 After days of research and re-coding I am pretty much stumped. My goal is to get a test app running with a single tableview populated from two separate fetchedResultControllers. I have a series of items on a shopping list, each with a department and a boolean 'collected' flag. Uncollected items should be listed by department, followed by a single section containing all collected items (regardless of department). As a user checks off uncollected items, they should move down to the 'collected'

Core Data sectionNameKeyPath with Relationship Attribute Performance Issue

做~自己de王妃 提交于 2019-12-04 07:56:37
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 relationship, the NSFetchedResultsController fetches everything upfront in small batches of 20 (I have

Deriving UITableView sections from NSFetchedResultsController using “to many” relationship

喜夏-厌秋 提交于 2019-12-04 06:59:17
My Core Data model looks like this: article <--->> category Is it even remotely possible to use NSFetchedResultsController to produce a UITableView that looks something like this? Category 1 - Article A - Article B - Article C Category 2 - Article A - Article D - Article E - Article F Category 3 - Article B - Article C Specifically, I'm interested in the (edge?) case where each UITableView section has a unique title (eg, "Category 1", "Category 2"), but the same object can exist in multiple sections (eg, Article A exists in both Category 1 and Category 2). I have scoured Apple's Core Data docs

NSFetchedResultsController index beyond bounds

感情迁移 提交于 2019-12-04 06:26:22
I'm using an NSFetchedResultsController to display items in my table view: - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { // Return the number of sections. return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { // Return the number of rows in the section. return [[self.fetchedResultsController fetchedObjects] count]; } // Customize the appearance of table view cells. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"TagCell";

UICollectionView with Multiple subclassed UICollectionViewCell

匆匆过客 提交于 2019-12-04 02:38:50
I have multiple sections in my UICollectionView grouped by "datasetType". I also have a custom UICollectionViewCell for each section. How can I determine which custom UICollectionViewCell I need in the cellForItemAtIndexPath method? My first though was go to based of the [sectionInfo name] : id sectionInfo = [[self.fetchedResultsController sections] objectAtIndex:indexPath.section]; if ([[sectionInfo name] isEqualToString:@"DatasetA"]) { DatasetACell *datasetACell = [collectionView dequeueReusableCellWithReuseIdentifier:datasetACellIdentifer forIndexPath:indexPath]; DatasetA *datasetA = [self