nsfetchedresultscontroller

NSFetchedResultsController ignores fetchLimit?

拥有回忆 提交于 2019-11-30 11:54:25
问题 I have a NSFetchedResultsController to update a UITableView with content from Core Data. It's pretty standard stuff I'm sure you've all seen many times however I am running into slight problem. First here's my code: NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:@"Article" inManagedObjectContext:self.managedObjectContext]; [fetchRequest setEntity:entity]; [fetchRequest setFetchLimit:20]; NSPredicate *predicate =

NSFetchedResultsController is not showing all results after merging an `NSManagedObjectContextDidSaveNotification`

回眸只為那壹抹淺笑 提交于 2019-11-30 10:15:37
I have an NSFetchedResultsController which fetches objects with a predicate: isTrash == NO Most of the time this works as expected, but when an object gets untrashed the fetched results controller does not fetch the untrashed object. What's going wrong? The reason why this is happening is due to how mergeChangesFromContextDidSaveNotification: handles updated objects. NSManagedObjectContext keeps a record of objects which are in use in the context, these are referred to as registered objects ( NSManagedObjectContext has methods for accessing and conditionally fetching registered objects).

Core Data Table View Section Sort by weekdays using NSSortDescriptor

╄→гoц情女王★ 提交于 2019-11-30 07:02:25
问题 I'm currently trying to sort my array of objects into day order so they can be grouped in the correct order i.e. Monday, Tuesday, Wednesday then by start time. Only problem is I can't figure out how to do this, my code currently looks like this: Which sorts alphabetically then by time: NSString *sectionKey = nil; switch (tab) { case kByWeekA: { NSSortDescriptor *sortDescriptor1 = [[NSSortDescriptor alloc] initWithKey:@"day" ascending:NO]; NSSortDescriptor *sortDescriptor2 = [[NSSortDescriptor

'NSFetchedResultsController does not support both change tracking and fetch request's with NSDictionaryResultType'

╄→гoц情女王★ 提交于 2019-11-30 06:49:51
I have an application that was running just fine under OS3+. But it does not work under OS4. I get the following error message: 'NSFetchedResultsController does not support both change tracking and fetch request's with NSDictionaryResultType' Does it ring a bell to anyone here? - (NSFetchedResultsController *)fetchedResultsController { if (fetchedResultsController != nil) { return fetchedResultsController; } /* Set up the fetched results controller. */ // Create the fetch request for the entity. NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; // Edit the entity name as

Custom sorting with NSFetchedResultController (subclassing NSSortDescriptor)

最后都变了- 提交于 2019-11-30 05:15:09
问题 I want to provide custom sorting using NSFetchedResultsController and NSSortDescriptor. As custom sorting via NSSortDescriptor message -(id)initWithKey:ascending:selector: is not possible (see here), I tried to use a NSSortDescriptor derived class in order to override the compareObject:toObject: message. My problem is that the compareObject:toObject: is not always called. It seems that it is called only when the data are already in memory. There is an optimization of some sort that use a

When is viewDidLoad called?

人盡茶涼 提交于 2019-11-30 04:46:38
问题 Is it safe to assume that an attribute, namely fetchedResultsController , of chatViewController , an instance of a subclass of UITableViewController , is always nil when viewDidLoad is called, assuming that it's set to nil in viewDidUnload ? Phew! If that's the case, then I see no immediate need to redefine the accessor function like in the Xcode example application CoreDataBooks. I'd rather just put all that code in viewDidLoad instead of in a separate function because that's the only place

NSPredicate and CoreData - decide if a Date attribute is “today” (or between last night 12am to tonight 12am) on iOS

我与影子孤独终老i 提交于 2019-11-30 03:45:45
问题 I'm using a NSFetchedResultsController and a UITableViewController to populate a UITableView from a CoreData database. I have a NSDate object saved into this Date attribute labeled "startTime". Then I'm trying to only pull todays's data by using a NSPredicate that looks like this: NSPredicate *predicate = [NSPredicate predicateWithFormat:@"startDate == %@", todaysDate]; I'm getting zero results. I understand this because a NSDate object just hold the number of seconds or milliseconds or

Changing the Sorting in an NSFetchedResultsController on the fly

匆匆过客 提交于 2019-11-30 01:55:43
I'm trying to change the sorting in a NSFetchController on the fly, by some sort of segmented control. To either sort A->Z Z->A type thing. What do I have to do to do this? I'm following Jeff Lamarche's example here: Here Do I need to make a new NSFetchedResultsController and then set it, or do I just make a new NSFetchRequest and do fetchedResultController.fetchRequest = newFetchRequest and then my table will automatically update? I was stuck with the same problem and I could fix it with just setting the sort descriptors on the FetchRequestController's FetchRequest, then execute a fetch

NSFetchedResultsController ignores fetchLimit?

对着背影说爱祢 提交于 2019-11-30 01:41:07
I have a NSFetchedResultsController to update a UITableView with content from Core Data. It's pretty standard stuff I'm sure you've all seen many times however I am running into slight problem. First here's my code: NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:@"Article" inManagedObjectContext:self.managedObjectContext]; [fetchRequest setEntity:entity]; [fetchRequest setFetchLimit:20]; NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(folder.hidden == NO)"]; [fetchRequest setPredicate:predicate];

(NSFetchedResultsController): couldn't read cache file to update store info timestamps

白昼怎懂夜的黑 提交于 2019-11-30 01:21:15
I upgraded my project to Xcode 8. Now, I'm getting this error log with Xcode 8 and iOS 10 combination. Setting the cacheName to nil in the below code seems fix it. NSFetchedResultsController *frc = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:self.managedObjectContext sectionNameKeyPath:NULL cacheName:@"myCache"]; What should I do to get rid of this error log and use cache in my FRC? This error should not be ignored because it can cause app crash. It is related to an iOS 10 bug of file descriptor leaks. There are reports on openradar and Apple Bug