NSFetchRequest includesPendingChanges and propertiesToFetch

342 views Asked by At

Is there a way to get a specific column / property of data e.g. (date) from my objects while using the pending changes option?

I want to be able to search my pending changes that have not been saved yet, but I also want only a specific column. I do not need the entire object. I would basically like to get distinct dates and return them in an array.

Another option is to just get the entire object but be able to use includesPendingChanges and Distinct, if this is possible.

1

There are 1 answers

0
Bot On BEST ANSWER

I ended up using an NSFetchController based on the code here. I based my fetch controller like this.

NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:[[DataManager sharedInstance] managedObjectContext] sectionNameKeyPath:@"date" cacheName:@"List"];

This grouped all my objects based on the date so when I needed the unique dates, I just needed to call the [fetchedResultsControllers sections].