1

I have a core data model with one record having a to many relationship to photos entity. The relationship is flagged as ordered in the data model.

The code below adds a new record at the last index. I want records to be ordered by date - meaning I have to insert the object at some specific index

 let photo = NSEntityDescription.insertNewObject(forEntityName: photoKey, into: self.managedObjectContext()) as! Photo

Is there a way to have core data perform a block or some operation to determine the correct insertion index for the new record? Or do I have to calculate it myself?

I'm concerned about order because photo deletions force the need to recalculate the date range of all photos.

Alex Stone
  • 46,408
  • 55
  • 231
  • 407

0 Answers0