HomeiOS Developmentios - How one can use sortDescriptors so as to fetch knowledge...

ios – How one can use sortDescriptors so as to fetch knowledge from the earlier view?


the issue I’ve encountered is that once I fetch the information with none type descriptor I obtain the entire checklist of information saved in CoreData, nevertheless, I wish to type it so the consumer would see the information he entered within the explicit view. The logic is that this: I’ve a TermDefinitionView the place consumer enters the information 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 knowledge consumer entered.

here is the a part of SetView():

import SwiftUI
import CoreData

struct SetView: View {
    
    var identify: String
    @Setting(.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(Shade.white)
                .overlay(RoundedRectangle(cornerRadius: 25).stroke(getColor(), lineWidth: 2))  // Right here we modify the border colour based mostly on the swipe path
                .shadow(radius: 3)

           
                VStack {
                    ForEach(flashCardData) { flashcards in
                                 //   FlashcardView(flashcard: flashcard)
                        Textual content(flashcards.identify ?? "nothing")
                        Textual content(flashcards.time period ?? "nothing")
                        
                        if isShown {
                            Textual content(flashcards.definition ?? "nothing")
                        }
                    }
                }

the result I get without sort descriptor:

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments