'How can i do do background fetch requests with swift ui

i'm doing dictionary so i have to do some research, for that i use core data and Fetch Request, i implemented my fetch request in my swiftui view like this :

@FetchRequest(sortDescriptors: [], predicate:NSPredicate(format: "ANY japonaisSet.kanji CONTAINS ''"))

and i modify it by modifing the nsPredicate with that :

@State var recherche:String = ""
    
    var query:Binding<String>
    {
        Binding
        {
            recherche
        }
        set:
        { newValue in
            recherche = newValue
            findedMots.nsPredicate = NSPredicate(format: "ANY japonaisSet.kanji CONTAINS %@", newValue)
        }
    }

but how can i make my fetch request in a background thread, i'm not using any managed Object Context in my swift ui view so i cant use any background context...



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source