Hi,
I'm creating a To-do list app with SwiftUI. There's a main 'List' view with all the lists users create. When you tap on a list, it takes you to the Detail View with the items in the list. The problem is, when I make a change to the list in the Detail View, it doesn't change in the main list.
The changes are indeed getting saved, as if I restart the app, the changes are persistent.
I've looked at similar issues but none of the solutions seem to be working.
Please suggest what might be the solution! Thanks!
I'm creating a To-do list app with SwiftUI. There's a main 'List' view with all the lists users create. When you tap on a list, it takes you to the Detail View with the items in the list. The problem is, when I make a change to the list in the Detail View, it doesn't change in the main list.
The changes are indeed getting saved, as if I restart the app, the changes are persistent.
I've looked at similar issues but none of the solutions seem to be working.
Code Block swift struct HomeView: View { @Environment(\.managedObjectContext) var viewContext @FetchRequest(entity: ItemGroup().entity, sortDescriptors: [NSSortDescriptor(keyPath: \ItemGroup.createdAt, ascending: false)]) var groups: FetchedResults<ItemGroup> var body: some View { NavigationView { List { Section { ForEach(groups, id: \.self) { group in NavigationLink(destination: DetailView(group: .constant(group)), label: { GroupRow(group: group) }) // ...
Code Block swift struct GroupRow: View { @ObservedObject var group: ItemGroup var body: some View { VStack(alignment: .leading) { ProgressView(value: group.progress) Text(group.wrappedName) Text("\(group.ongoingItems.count) Ongoing") } } }
Code Block swift struct DetailView: View { @Environment(\.managedObjectContext) private var viewContext @FetchRequest(entity: Item().entity, sortDescriptors: [NSSortDescriptor(keyPath: \Item.createdAt, ascending: false)]) private var items: FetchedResults<Item> @Binding var group: ItemGroup var body: some View { ...
Please suggest what might be the solution! Thanks!