mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
21 lines
583 B
Swift
21 lines
583 B
Swift
import CoreData
|
|
import Foundation
|
|
|
|
public extension Recommendation {
|
|
var unwrappedID: String { id ?? "" }
|
|
|
|
static func lookup(byID recommendationID: String, inContext context: NSManagedObjectContext) -> Recommendation? {
|
|
let fetchRequest: NSFetchRequest<Models.Recommendation> = Recommendation.fetchRequest()
|
|
fetchRequest.predicate = NSPredicate(
|
|
format: "id == %@", recommendationID
|
|
)
|
|
|
|
var recommendation: Recommendation?
|
|
|
|
context.performAndWait {
|
|
recommendation = (try? context.fetch(fetchRequest))?.first
|
|
}
|
|
|
|
return recommendation
|
|
}
|
|
}
|