21 lines
456 B
Swift
21 lines
456 B
Swift
//
|
|
// NSManagedObjectContext+Helpers.swift
|
|
// Tusker
|
|
//
|
|
// Created by Shadowfacts on 5/9/22.
|
|
// Copyright © 2022 Shadowfacts. All rights reserved.
|
|
//
|
|
|
|
import CoreData
|
|
|
|
extension NSManagedObjectContext {
|
|
func objectExists<T: NSFetchRequestResult>(for request: NSFetchRequest<T>) -> Bool {
|
|
switch try? count(for: request) {
|
|
case nil, 0, NSNotFound:
|
|
return false
|
|
default:
|
|
return true
|
|
}
|
|
}
|
|
}
|