我正在使用FSCalendar显示事件,我希望每年都能显示来自api的某些事件 . 如何在代码中设置它?我尝试使用 numberOfEventsFor ,但我得到的代码是在Obj-C中 . 转换为Swift 4后,FSCalendar没有成员 dayOf . 最初的Obj-C代码是:

- (NSInteger)calendar:(FSCalendar *)calendar numberOfEventsForDate:(NSDate *)date
  {
   return [calendar dayOfDate:date] == 2 ? 1 : 0;
  }

numberOfEventsFor 是为重复发生的事件提供逻辑的正确位置还是将它放在 willDisplay 更好?