Closed psides83 closed 4 years ago
I think I understand your question. I don't think I would do anything directly with the ForEach. I would add a new function to my data source that builds and executes a separate Core Data query. It would build a scalar query using the same predicate that the query for the ForEach uses. Depending on how you use the query results in your View, you might have to play around with how/when the query get executed. I hope this helps.
Thanks for redirecting my thinking on this. I only started learning programming last month. Building a func to calculate using the same predicate worked perfectly.
I do have another unrelated question that I'll bring up in a new thread.
First of all, thank you so much for this. It’s been exactly what I’ve needed to help me with my first app project. This covers a lot of what I’ve been stuck on for weeks now.
Anyway my question is this, how could I run a .reduce on the “ForEach(dataSource.loadDataSource(related...”?
For example... Using you’re test structure, if I was in the ItemEditView and wanted to get a sum of the Attribute.order instances for that specific “Item”. Can you help with that?