the issue I’ve encountered is that after I fetch the info with none type descriptor I obtain the entire record of information saved in CoreData, nevertheless, I wish to type it so the consumer would see the info he entered within the specific view. The logic is that this: I’ve a TermDefinitionView the place consumer enters the info after which it saves utilizing CoreData, after the consumer presses “save” button, he/she is relocated to the SetView – the view with the stack of flashcards based mostly on information consumer entered.
this is the a part of SetView():
import SwiftUI
import CoreData
struct SetView: View {
var title: String
@Surroundings(.managedObjectContext) non-public var viewContext
// @FetchRequest(entity: FlashCardData.entity(), sortDescriptors: NSSortDescriptor[key: ])
@FetchRequest(
entity: FlashCardData.entity(),
sortDescriptors: [
])
var flashCardData: FetchedResults<FlashCardData>
let dataController = DataController.shared
var elimination: (() -> Void)? = nil
var onRemove: ((SwipeDirection) -> Void)? = nil
@State non-public var isShown = false
@State non-public var offset = CGSize.zero
@State non-public var label: String = "Nonetheless Studying" // Outline a label string
@State non-public var showPositiveIndicator = false
@State non-public var showNegativeIndicator = false
@State non-public var showMiddleIndicator = false
@State non-public var showEasyIndicator = false
@State var redirectToSet = false
var physique: some View {
ZStack {
RoundedRectangle(cornerRadius: 25, fashion: .steady)
.fill(Colour.white)
.overlay(RoundedRectangle(cornerRadius: 25).stroke(getColor(), lineWidth: 2)) // Right here we modify the border coloration based mostly on the swipe route
.shadow(radius: 3)
VStack {
ForEach(flashCardData) { flashcards in
// FlashcardView(flashcard: flashcard)
Textual content(flashcards.title ?? "nothing")
Textual content(flashcards.time period ?? "nothing")
if isShown {
Textual content(flashcards.definition ?? "nothing")
}
}
}