Search code examples
xcodeswifticloudcloudkit

How to organize icloud data by date added?


I am making an app that uses cloud-kit, and when I ask it to return the data saved on it, its out of order. How to i organize the data by date? And then save it in an array, with array [0] as the most recent data added? by the way, the view controller that saves the data is a different view controller that loads it.


Solution

  • You could ad a sort order to your query like this:

    query.sortDescriptors = [NSSortDescriptor(key: "creationDate", ascending: false)]