let sortedFiles = objects.sorted {
if let time1 = $0.resourceValues.contentModificationDate?.timeIntervalSinceReferenceDate,
let time2 = $1.resourceValues.contentModificationDate?.timeIntervalSinceReferenceDate {
return time1 > time2
} else {
return false
}
}
this will remove recent file, generally speaking should remove the file which older not the recent
let sortedFiles = objects.sorted { if let time1 = $0.resourceValues.contentModificationDate?.timeIntervalSinceReferenceDate, let time2 = $1.resourceValues.contentModificationDate?.timeIntervalSinceReferenceDate { return time1 > time2 } else { return false } } this will remove recent file, generally speaking should remove the file which older not the recent