In a core data entity containing multiple objects, how to access a specific object outside of using ForEach
I have tried using filtering the results with NSPredicate but that does not work even when only one object fits the description
For example, I want to be able to edit something outside the ForEach
loop, and update it into the latest core data entry
struct ContentView: View {
@FetchRequest(entity: NameData.entity(), sortDescriptors: []) var names : FetchedResults<NameData>
var body: some View{
VStack{
Text("Edit Latest Entry")
// Textfields for editing first and last names
ForEach(self.names){ name in
Text(name.firstName)
Text(name.lastName)
}
}
}
}