Post

Replies

Boosts

Views

Activity

List Core Data Entity Relationships
How do I list the relationships of a particular entity that is fetched?I know how to list the entries for the entity itself, but I can't figure out how to list one-to-many relationships in a List.See this code:struct TodoItemView: View { var todoList: TodoList var body: some View { VStack { Text(todoList.title!) List { ForEach(todoList.todoItems, id: \.self) {todoItem in Text(todoItem.title!) } } } } }That is producing errors and I have no clue how to fix them:Protocol type 'NSSet.Element' (aka 'Any') cannot conform to 'Hashable' because only concrete types can conform to protocolsValue of type 'NSSet.Element' (aka 'Any') has no member 'title'I've set up my TodoList entity to have a one-to-many with TodoITem. I fetch the todoList in the previous view and then pass it to this view:@Environment(\.managedObjectContext) var managedObjectContext @FetchRequest( entity: TodoList.entity(), sortDescriptors: [NSSortDescriptor(key: "order", ascending: true)] ) var todoLists: FetchedResults<TodoList> // ...more code here List { ForEach(todoLists, id: \.self) {todoList in NavigationLink(destination: TodoItemView(todoList: todoList), label: { Text(todoList.title!).foregroundColor(stringToColor(string: todoList.color!)) }) } }How do I use todoList.todoItems in a ForEach loop the same way so that I can also run CRUD operations on it as well?
6
0
3.6k
Nov ’19
Cancel back gesture bug with NavigationView
I'm not sure how to fix this or if it is even fixable. When I hold the back swipe gesture in my SwiftUI app it completely bugs out and the navigation gets screwed up. It works fine if I do a complete back swipe, but if I pause at any time while swiping this bug occurs.See this example gif:https://imgur.com/WqOqUlGIs there solution for this at all? I'm using a standard `NavigationView` with a `NavigationLink`.
12
0
5.1k
Nov ’19