iOS 15: One-to-many relationships with @FetchRequest and SwiftUI – Core Data SwiftUI Tutorial 7/7
Why Stack Overflow recommends it
Stack Overflow users link it as a worked example when they are stuck on Core Data relationships, NSSet properties, or modelling parent and child entities in SwiftUI apps.
Recommended by 0 people across 0 different months, 2021 to 2023.
What it is
Part 7 of Paul Hudson's Core Data series from his 100 Days of SwiftUI course. It shows how to model one-to-many relationships in Core Data and display and filter the related objects with @FetchRequest in SwiftUI, building on the earlier parts of Project 12.
What people said
Cites Justin Comstock · 2021-12 · Stack Overflow · on “How to handle deduplication with CoreData and CloudKit?”
I can't find any updated tutorials on CloudKit with CoreData + SwiftUI . CloudKit does not support constraints then how do I merge duplicate records for my case? I need to know what to do now that I had to disable CoreData constraints and the merge policy that I had in place. I have been following along with this tutorial. [this video] This is a simple code to take a form and save a todo to the viewContext and set the relationship to the category they selected. Which this now creates duplicate Categories which I do not want. let newTodo = Todo(context: viewContext) newTodo.title = title newTodo.dueDate = dueDate newTodo.relationship = Category(context: viewContext) newTodo.relationship?.title = c
Cites JR10 · 2023-03 · Stack Overflow · on “Why is core data is not retrieving relationship values through extension?”
I have 2 entities in Core Data, Plans and Places. They are connected with one-to-many relationship (one event in a plan ("Space Mountain"), to many in Places "Magic Kingdom")). The expectation is the user can tap on an item, like "Space Mountain", choose a date, and that item and selected date are added to the itinerary. The itinerary shows "Magic Kingdom" which I've also successfully added to the Places Entity. It's all working, except retrieving from the relationship. The title and date (stored in Plans) show up fine , but the associated location and park (stored in Places) return my nil string . Any idea what I'm doing wrong? I've gone back through all the videos and books and everything
Cites Fronk · 2023-06 · Stack Overflow · on “Core Data unrecognized selector sent to instance when trying to access a NSSet property”
Could you elaborate @Paulw11 ? How can i do this? Besides i don't think that is the problem. I found this tutorial and it works there [this video]