UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

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 RevenueCat

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

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.