JTAppleCalendar
JTAppleCalendar copied to clipboard
JTACMonthLayout Crash
(Required) Version Number: 8.0.3
Description
#0 0x000000010483853c in JTACMonthLayout.setupDataFromDelegate() at ~/Pods/JTAppleCalendar/Sources/JTAppleCalendar/JTACMonthLayout.swift:168 JTAppleCalendar was compiled with optimization - stepping may behave oddly; variables may not be available.
Line 168: strictBoundaryRulesShouldApply = thereAreHeaders || delegate._cachedConfiguration.hasStrictBoundaries
Steps To Reproduce
func setupCalendarView() {
calendarView.minimumLineSpacing = 0
calendarView.minimumInteritemSpacing = 0
calendarView.visibleDates { (visibleDates) in
self.setupViewsOfCalendar(from: visibleDates)
}
if(self.appoDates.count > 0) {
self.calendarView.selectDates(self.appoDates)
}
self.formatter.dateFormat = "yyyy MM dd"
self.calendarView.selectDates([formatter.date(from: getTodayDate())!])
}
func setupViewsOfCalendar(from visibleDates: DateSegmentInfo){
let date = visibleDates.monthDates.first!.date
formatter.dateFormat = "yyyy"
year.text = formatter.string(from: date)
formatter.dateFormat = "MMMM"
month.text = formatter.string(from: date).capitalized
}
Expected Behavior
Additional Context
is it possible you can provide a sample app with this crash?
I am also getting the same crash. Any luck with solving that @cesariel ?
@umarchohan is it possible you can create a sample app (a barebones minimal app with no company code inside it) that recreates this issue?
@patchthecode you can check with these settings as per @cesariel
func setupCalendarView() {
calendarView.minimumLineSpacing = 0
calendarView.minimumInteritemSpacing = 0
calendarView.visibleDates { (visibleDates) in
self.setupViewsOfCalendar(from: visibleDates)
}
if(self.appoDates.count > 0) {
self.calendarView.selectDates(self.appoDates)
}
self.formatter.dateFormat = "yyyy MM dd"
self.calendarView.selectDates([formatter.date(from: getTodayDate())!])
}
func setupViewsOfCalendar(from visibleDates: DateSegmentInfo){
let date = visibleDates.monthDates.first!.date
formatter.dateFormat = "yyyy"
year.text = formatter.string(from: date)
formatter.dateFormat = "MMMM"
month.text = formatter.string(from: date).capitalized
}
if you are using the same code.
Can you confirm that it is not crashing at the forced optional values?
I see you force the values
here --> self.calendarView.selectDates([formatter.date(from: getTodayDate())!])
and here -> let date = visibleDates.monthDates.first!.date
using the !
character.
I'm encountering this same issue in version 8.0.3.
The crash is caused by this implicitly unwrapped optional in JTACMonthView.swift:115
:
// Configuration parameters from the dataSource
var _cachedConfiguration: ConfigurationParameters!
which is used in JTACMonthLayout.Swift:168
:
strictBoundaryRulesShouldApply = thereAreHeaders || delegate._cachedConfiguration.hasStrictBoundaries
A nil
value for _cachedConfiguration
crashes the app. Since this is an internal property, I believe the library should be updated to avoid force unwrapping, and guard or handle nil values rather than crashing.
this happened in production mode or in development? And how did it happen?
this happened in production mode or in development? And how did it happen?
Production build. In my comment above I describe why the crash occurred, but since _cachedConfiguration
is internal to JTAppleCalendar, I don't know what circumstances could cause it to be nil
.