WenchaoD / FSCalendar

A fully customizable iOS calendar library, compatible with Objective-C and Swift

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Attempted to modify the selection of an item in an out-of-bounds section (647) when there are only 647 sections.

zhhehj13 opened this issue · comments

Attempted to modify the selection of an item in an out-of-bounds section (648) when there are only 648 sections. Collection view: <FSCalendarCollectionView: 0x10a04f200; baseClass = UICollectionView; frame = (0 0; 0 0); clipsToBounds = YES; gestureRecognizers = <NSArray: 0x282c844e0>; backgroundColor = UIExtendedGrayColorSpace 0 0; layer = <CALayer: 0x28228c8a0>; contentOffset: {0, 0}; contentSize: {0, 0}; adjustedContentInset: {0, 0, 0, 0}; layout: <FSCalendarCollectionViewLayout: 0x10914ad90>; dataSource: <FSCalendar: 0x109345d30; frame = (0 0; 0 0); layer = <CALayer: 0x2822845a0>>>.

cocoapods安装

  • 设备型号及版本。 例如: iPhone14 iOS17.1.2
  • 使用的Xcode版本。 Xcode15`
  • FSCalendar版本. FSCalendar 2.8.4

I am getting same issue in production app, below is stack trace
Screenshot 2024-03-29 at 12 27 05 PM

@WenchaoD can you please check this issue

FSCalendar has a working range of dates minimumDate - maximumDate, by defaults it's 1970-01-01 and 2099-12-31
I noticed strange behavior of minimumDate calculation for some time zones (e.g. America/Mazatlan (GMT-7))

NSDate *newMin = [self.dataSourceProxy minimumDateForCalendar:self]?:[self.formatter dateFromString:@"1970-01-01"];
newMin = [self.gregorian dateBySettingHour:0 minute:0 second:0 ofDate:newMin options:0];

here newMin will be 1970-01-01 01:00:00 however for any other date an hour component will be set to 0 hours
(e.g. 1970-01-02 00:00:00)
Because of this, calculations like - (NSIndexPath *)indexPathForDate:(NSDate *)date scope:(FSCalendarScope)scope are broken and leads to crash on iOS 17

There is a way to change minimumDate by implementing dataSource method to avoid such behavior

/**
 * Asks the dataSource the minimum date to display.
 */
- (NSDate *)minimumDateForCalendar:(FSCalendar *)calendar;