Search code examples
core-datasortingtimestampinsert-id

Retrieve Core Data Entities in Order of Insertion


Is there an internal ID variable or timestamp I can use in a NSSortDescriptor to retrieve Core Data entities in the order they were inserted?

I would rather not have to create such properties if there is a cleaner way, though will obviously do so if there are no other alternatives.


Solution

  • No, if you want a sort order for your data, you need to add that to your entities yourself. However you can easily add a NSDate attribute that has a default value of "NOW" so that it will auto-populate.