CoreStore
CoreStore copied to clipboard
I try to sort datetime by descending order
I make variable
let fetchingItems = [ { (newDate) -> [DataType] in
return try! UserDataManager.dataStack.fetchAll(From<DataType>(UserDataManager.veggieConfiguration)
.where(format: "%K BEGINSWITH[c] %@",#keyPath(DataType.createdDate),newDate).orderBy(.descending(\.createdDate)))
},
{ (newDate) -> [DataType] in
return try! UserDataManager.dataStack.fetchAll(From<DataType>(UserDataManager.fruitsConfiguration)
.where(format: "%K BEGINSWITH[c] %@",#keyPath(DataType.createdDate),newDate).orderBy(.descending(\.createdDate)))
} ]
DateTime is string type. I create datetime like "yyyy.MM.dd h:mm:ss a" I want to show recent data is first. When time changed 11pm, ordering didn't change.
I’m not sure if understand your issue, but fetchAll()
returns an array, and the ordering would be fixed during fetch time.
If you want a list that changes ordering dynamically, use ListPublisher
s or ListMonitor
s
Ok. I will check ordering works fine at night time. If didn't work, follow your advice. 🦊