Any thoughts?
Assume you want to call this isDateInToday(_:):
isDateInToday(_:) - https://developer.apple.com/documentation/foundation/calendar/2293243-isdateintoday
(When you ask something about functions defined in a framework, you should better include a link to the doc of it.)
In this case, isDateInToday is an instance method. When you want to call an instance method of some other type, you need to prefix instanceName:
instanceName.isDateInToday(oneTimeDate)
The instance needs to be of type Calendar, you can get the instance of the user's current Calendar with Calendar.current:
struct OneTimeRow: View {
let calendar = Calendar.current //- An instance of `Calendar`
//...
var body: some View {
//...
if calendar.isDateInToday(oneTimeDate) {
Text("Today at \(oneTimeDate, formatter: itemFormatter)")
} else if calendar.isDateInYesterday(oneTimeDate) { //- `isDateInYesterday`, not `isDateinYesterday`
Text("Yesterday at \(oneTimeDate, formatter: itemFormatter)")
} else if calendar.isDateInTomorrow(oneTimeDate) {
Text("Tomorrow at \(oneTimeDate, formatter: itemFormatter)")
} else {
//...
}
//...
}
}