|
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 .... |
|
|
|
BUILD THE ULTIMATE PORTFOLIO APP Most Swift tutorials help you solve one specific problem, but in my Ultimate Portfolio App series I show you how to get all the best practices into a single app: architecture, testing, performance, accessibility, localization, project organization, and so much more, all while building a SwiftUI app that works on iOS, macOS and watchOS.
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.