WenchaoD / FSCalendar

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to programmatically call performSelecting()

BrendanTipney opened this issue · comments

I need to have some of the dates show selected when the calendar view is loaded. Not just selected, but have them update and show selected in the UI. I understand from this comment that you cannot just set the date as selected, as this does not call the functions to update the cell appearance. I am guessing the best way to do this is to call the following function in my FSCalendarDataSource extension.

  func calendar(_ calendar: FSCalendar, cellFor date: Date, at position: FSCalendarMonthPosition) -> FSCalendarCell {
        let cell = calendar.dequeueReusableCell(withIdentifier: FSCalendarBlankCellReuseIdentifier, for: date, at: position)

        if habit.record[date] == true{
           cell.performSelecting()
        }

        return cell
    }

But it crashes on return. I would think this is because I need to call reloadDataForCell to load the current values for that cell back in. But I am not sure how to call this function correctly. Am I going about this the wrong way?

Device iphone 12Pro
Xcode 12.4
FSCalendar 2.8.2