nsfetchrequest

NSFetchedResultsController trying to limit number of records displayed

两盒软妹~` 提交于 2019-12-06 15:11:08
问题 When creating a NSFetchRequest to pass over to my NSFetchedResultsController I am setting the fetchLimit property to 3. Now initially this appears to work fine. I can modify the first three returned objects in any way which changes their order and they all reshuffle correctly. The problem appears when I either alter a object which initially fell outside the first three in a way which now brings it into the first three, or when simply adding a new object so it will appear within the first

Exception raised by NSExpressionDescription with Core Data in-memory store

帅比萌擦擦* 提交于 2019-12-06 14:03:44
问题 I use this NSExpressionDescription to get the max value for the attribute date_modified: NSFetchRequest *dateModifiedFR = [[NSFetchRequest alloc] initWithEntityName:@"MyEntity"]; dateModifiedFR.resultType = NSDictionaryResultType; NSExpression *keyPathExpression = [NSExpression expressionForKeyPath:@"date_modified"]; NSExpression *maxDateExpression = [NSExpression expressionForFunction:@"max:" arguments:@[keyPathExpression]]; NSExpressionDescription *expressionDescription = [

Is it possible to have Core Data sort the “many” part of a To-Many relationship during a fetch request?

给你一囗甜甜゛ 提交于 2019-12-06 12:38:41
I'm using Core Data to cache a decent amount of information, and I have a To-Many relationship set up among my managed objects. Naturally I use an NSFetchRequest to fetch an array of the singular side of that relationship. However, I populate a UITableView using the the "many" side of the relationship, and I'd like it to be sorted alphabetically when I pull the data. If I'm not being clear, here's an example: "employee" and "boss" are both NSManagedObjects in a To-Many relationship - each boss has many employees, but employees only have one boss. After retrieving an array of bosses, I push a

How to sort based on a calculated value from multiple Core Data attributes

送分小仙女□ 提交于 2019-12-06 10:16:15
I'm trying to create a sort descriptor, for a core data fetch request, that will fetch objects that are ordered by a calculated value (e.g., the sum of two or more attributes). Is this possible? Thanks in advance. From the "Core Data Programming Guide": You cannot fetch using a predicate based on transient properties (although you can use transient properties to filter in memory yourself). ... To summarize, though, if you execute a fetch directly, you should typically not add Objective-C-based predicates or sort descriptors to the fetch request. Instead you should apply these to the results of

setFetchBatchSize doesn't seem to work properly

断了今生、忘了曾经 提交于 2019-12-06 08:25:25
问题 I ask a few questions on this topic but still can't get it to work. I have a core data with 10k+ rows of people names that i am showing in a tableview. I would like to be able to search and update the table with every letter. It's very laggy. As suggested i watch the WWWDC '10 core data presentation and was trying to implement [request setFetchBatchSize:50]; Doesn't seem to work. When i use instruments to check core data it still shows that there is still 10k request when loading the

Core Data one-to-many sorting

梦想的初衷 提交于 2019-12-06 06:31:48
问题 I have CoreData object "Entity" with @property (nonatomic, retain) NSSet *ImagesSet; Inside ImagesSet are many "ImageEntity" objects. "ImageEntity" have @property (nonatomic, retain) NSNumber * sortKey; How create fetchRequest for "Entity" with imagesSet ordered by sortKey field? NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:@"Entity" inManagedObjectContext:[[DataManager sharedInstance] mainObjectContext]];

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

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,

Saving and Deleting NSManagedObject & NSManagedObjectContext

匆匆过客 提交于 2019-12-06 03:00:51
Three Questions but they are all related. If you like I can divide them into three questions so that you can more credits. Let me know if you'd like for me to do that. I have the following code that allows me to access NSManagedObject self.managedObjectContext = [(STAppDelegate *)[[UIApplication sharedApplication] delegate] managedObjectContext]; NSError *error; NSFetchRequest *request = [[NSFetchRequest alloc] init]; [request setEntity:[NSEntityDescription entityForName:@"LetsMeet" inManagedObjectContext:managedObjectContext]]; NSArray *objectArray = [managedObjectContext executeFetchRequest

FetchRequest - NSArray element failed to match the Swift Array Element type - Swift 2.0

拜拜、爱过 提交于 2019-12-06 02:41:03
问题 I want to do a NSFetchRequest to display my data into a UICollectionView : import UIKit import CoreData let appDelegate: AppDelegate = UIApplication.sharedApplication().delegate as! AppDelegate let context: NSManagedObjectContext = appDelegate.managedObjectContext class GarageViewController: UIViewController, UICollectionViewDelegate,UICollectionViewDataSource { @IBOutlet weak var backgroundView: UIImageView! @IBOutlet weak var collectionView: UICollectionView! var voitures: [Voiture] =