In the Sidebar, the badge doesn't show up for me. This is also the case with the end product:
ForEach(store.gardens(in: store.currentYear)) { garden in
Label(garden.name, systemImage: "leaf")
.badge(garden.numberOfPlantsNeedingWater)
}
In the Sidebar, the badge doesn't show up for me. This is also the case with the end product:
ForEach(store.gardens(in: store.currentYear)) { garden in
Label(garden.name, systemImage: "leaf")
.badge(garden.numberOfPlantsNeedingWater)
}
Odd. Yes, works for me with their sample and in my own project.
Yeah I'm not sure what's going on. I'm running Monterey with the latest Xcode 13 beta. I'm kind of lost at the point.
Hi
For me, there is a mistake in the Plant.swift file for the needsWater computed property.
return lastWateredOn.timeIntervalSince(Date()) > TimeInterval(wateringFrequency) * 24
IS WRONG and should be:
return Date().timeIntervalSince(lastWateredOn) > TimeInterval(wateringFrequency) * 24 * 60 * 60
The interval is from lastWateredOn until Now and not the opposite.
So the initial code lastWateredOn.timeIntervalSince(Date()) gives a negative value and the test is always false so no badge appears.
Regards
Vincent
Thanks, that fix works for me too.
Apologies, already answered correctly earlier.