Implemented the "allLocations()" static function in the NSFetchRequest+Location extension.

This commit is contained in:
Javier Cicchelli 2023-04-12 15:14:02 +02:00
parent 543417744b
commit 4f315d7bfb

View File

@ -0,0 +1,27 @@
//
// NSFetchRequest+Location.swift
// Persistence
//
// Created by Javier Cicchelli on 12/04/2023.
// Copyright © 2023 Röck+Cöde. All rights reserved.
//
import CoreData
public extension NSFetchRequest where ResultType == Location {
// MARK: Functions
static func allLocations() -> NSFetchRequest<Location> {
let request = Location.fetchRequest()
request.sortDescriptors = [
.init(keyPath: \Location.source, ascending: true),
.init(keyPath: \Location.createdAt, ascending: true)
]
request.resultType = .managedObjectResultType
return request
}
}