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
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: