WWDC21 SALE: Save 50% on all my Swift books and bundles! >>

How to pass DetailView parameters for child entities with CoreData?

Forums > Swift

I'm pretty sure this is something very basic but I cannot figure it out.

In my detail view, I use ObservedObjects to define the variables for every child entity, and display them. It works.

Eventually, it asks for me to pass a variable for the each ObservedObject. For the parent entity, I pass the variable defined within the ForEach. For child entities, I tried below approaches:

  • Created separate FetchRequests for each child entity, tried to pass the variables
  • Tried ForEach(zip(sequence1, sequence2, id: \0.self)) { seq1, seq2 in
  • Tried one above without the zip, and just the parent entity

I get the "unable to bla bla, please file a bug report" error in most cases. What am I doing wrong?

   

ForEach(zip(sequence1, sequence2, id: \0.self)) { seq1, seq2 in

Well, this isn't going to work because you have your parentheses wrong. It should be:

ForEach(zip(sequence1, sequence2), id: \0.self) { seq1, seq2 in

Note that I still don't know if that will do what you want it to do in the larger scope.

   

Thank you for pointing it out, another head smash for me for today.

I am now getting this now:

The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions

Is it Xcode's fault now? Any ideas on breaking it up further?

   

Save money with our WWDC sale!

SAVE 50% To celebrate WWDC21, all our books and bundles are half price, so you can take your Swift knowledge further without spending big! Get the Swift Power Pack to build your iOS career faster, get the Swift Platform Pack to builds apps for macOS, watchOS, and beyond, or get the Swift Plus Pack to learn advanced design patterns, testing skills, and more.

Save 50% on all our books and bundles!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.