|
Hi HWS Community, I am working on an App that presents some animal Cards in the Content View showing an image of the animal (for instance a dog) and I am trying to show the number of dogs currently in the Core Data. Here is the AnimalCard code:
Here is the ContentView code, it has 3 AnimalCards (Dog, Cat and Bird), the number is being hard coded. When you click the Card it takes you to the list of animals available in that category (dog, cat or bird). I also added a button to load some sample data.
Here is the AnimalListView file that will be shown with animal name and age.
Here is the FilteredList file. As you can see, I did add the fetchRequest.count to be shown in the AnimalListView.
Again, the question is how to take the count from the FilteredList and update the AnimalCard in the ContentView? Thanks for your help. Renato. |
|
Renato having fun with filters:
Seems you have all the data you need in the Consider building a computed property that filters the Paste into Playgrounds:
Careful! Your filter may return no objects! Keep Coding! |
|
Oooof. -20 points from Hufflepuff! +20 points for explanation (below). See -> FooBarView Please read and leave your thoughts .... |
|
|
|
TAKE YOUR SKILLS TO THE NEXT LEVEL If you like Hacking with Swift, you'll love Hacking with Swift+ – it's my premium service where you can learn advanced Swift and SwiftUI, functional programming, algorithms, and more. Plus it comes with stacks of benefits, including monthly live streams, downloadable projects, a 20% discount on all books, and free gifts!
Sponsor Hacking with Swift and reach the world's largest Swift community!
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.
Link copied to your pasteboard.