LAST CHANCE: 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?

3      

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.

3      

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?

3      

Hacking with Swift is sponsored by Essential Developer.

SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until July 28th.

Click to save your free spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

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.