简体   繁体   中英

CoreData sort by creation order

Wondering, if possible, how I would go about sorting entities from an NSSet by the order in which they were created.

I'm able to sort them by certain attributes, but can't work out how to sort by creation order.

Thanks

The only way to do this with Core Data is to provide a creationDate field in the Entity and fill this. You could fill this within the entity itself in -willSave for example, so that the controller that deal with your model does not have to mess with that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM