In the example project add a new event in the AllDayViewModel dated the previous week, like:
private let lastWeekDate = Date().add(component: .day, value: -8)
Add a jump-to-today function like this:
let now = Date()
self.calendarWeekView.updateWeekView(to: now)
self.calendarWeekView.updateFirstDayOfWeek(setDate: now, firstDayOfWeek: .Monday)
self.calendarWeekView.scrollWeekView(to: now)
Recompile and launch the example project
Set the calendar properties to show 7 days, first day of week to Monday
Scroll to the previous week
Execute the jump-to-today function
Observe the app crashes with:
Fatal error: LongPressEventCell and AllDayEvent should be casted: file JZCalendarWeekViewExample/LongPressWeekView.swift
as the getCurrentEvent(with indexPath: IndexPath) returns nil.
Steps to reproduce:
private let lastWeekDate = Date().add(component: .day, value: -8)
Observe the app crashes with:
Fatal error: LongPressEventCell and AllDayEvent should be casted: file JZCalendarWeekViewExample/LongPressWeekView.swift
as the
getCurrentEvent(with indexPath: IndexPath)
returnsnil
.