0
実行中のアプリケーションでは、コアデータから実行オブジェクトの配列を作成しています。しかし、私は日付でソートする必要があります(各実行オブジェクトには日付変数が関連付けられています)。私のコードは次のとおりです:実行オブジェクトの配列を日付でソートする(コアデータ)
func loadFromCoreData() {
let managedObjectContext = (UIApplication.sharedApplication().delegate as! AppDelegate).managedObjectContext
let runFetch = NSFetchRequest(entityName: "Run")
do {
let fetchedRuns = try managedObjectContext.executeFetchRequest(runFetch) as! [Run]
for run in fetchedRuns {
self.runs.append(run)
}
} catch let error as NSError {
fatalError("Failed to fetch run: \(error)")
}
}
機能が終了する前に、実行オブジェクト(実行と呼ばれます)の配列を日付順にソートするにはどうすればよいですか?
[コアデータソート記述子とNSDate、iOSとSwiftの可能な複製](http://stackoverflow.com/questions/30511999/core-data-sort-descriptor-with-nsdate-ios-with-swift) – ZGski