Ferrite-backup/Ferrite/Views/CommonViews/DynamicFetchRequest.swift
kingbri a89e832d1c Ferrite: Concurrency, cleanup, and format
Use strict concurrency checking in Xcode 14 to find misuses with
Swift concurrency.

Cleanup files and rearrange them along with fixing comment headers.

Signed-off-by: kingbri <bdashore3@proton.me>
2022-10-05 10:48:02 -04:00

29 lines
678 B
Swift

//
// DynamicFetchRequest.swift
// Ferrite
//
// Created by Brian Dashore on 9/6/22.
//
// Used for FetchRequests with a dynamic predicate
// iOS 14 compatible view
//
import CoreData
import SwiftUI
struct DynamicFetchRequest<T: NSManagedObject, Content: View>: View {
@FetchRequest var fetchRequest: FetchedResults<T>
let content: (FetchedResults<T>) -> Content
var body: some View {
content(fetchRequest)
}
init(predicate: NSPredicate?,
@ViewBuilder content: @escaping (FetchedResults<T>) -> Content)
{
_fetchRequest = FetchRequest<T>(sortDescriptors: [], predicate: predicate)
self.content = content
}
}