This is a pretty straightforward problem.
I have a CoreData database that gets initialized with a local file. The CoreData schema that looks like this:
Category -->> Objections -->> Responses -->> Evidence
("-->>" means, has many)
I am using an NSFetchedResultsController to retrieve objects from core data. Pretty standard.
NSEntityDescription *entity = [NSEntityDescription entityForName:NSStringFromClass([OHObjection class])inManagedObjectContext:self.managedObjectContext];
[fetchRequest setEntity:entity];
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"[suitable key]" ascending:YES];
NSArray *sortDescriptors = @[sortDescriptor];
[fetchRequest setSortDescriptors:sortDescriptors];
NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:self.managedObjectContext sectionNameKeyPath:@"category.objectionCategoryText" cacheName:nil];
Every "To Many" relationship is ordered.
Question: Is it possible to fetch the data in the order that it was created without using a timestamp or explicitly setting my own id?
Note: I have nothing against using timestamps or creating my own ID's, I just want to know if it is possible.
NSSortDescriptor
? with what key? Thanks. – Alek