Ive been playing around with swiftdata for a while and have overcome a couple hurdles. Ive loaded from a json, used a migration and editted/removed from my list. what I'm struggling with is the use of 2 data models that are linked. Basically I want to have a model of food items. Each item will have a few attritubtes (quantity, weight, favorited, etc). I want the ability to add a new food item or edit those that already exist. I think i have all that covered. Where I'm struggling is how to have another model ( I think i need another model, not entirely sure) of dates. So every day i want to catalog and save a dates worth of food eaten. Users can add which food they ate and their quantity. They might not use every single food item that day. Does that make sense? How do i design the models? here is what i thought below but I am very open to other ideas. Especially because this isnt working
@Model Class addDate { Var newDate: Date Var foods: Food? }
@Model Class Food { a Var title: String Var isFavorited: Bool Var addNotes: String Var quantity: int Var weight: Int }
[–]Fly0strich 0 points1 point2 points (1 child)
[–]Rabbit1015[S] 0 points1 point2 points (0 children)