I have an array of object contains bookings
class MonthBookings: NSObject {
var date: Date = Date()
var bookings_count: Int = 0
}
var bookings = [MonthBookings]()
So I need to check if cell date is equal to some date in bookings array then change cell color for this date in cell.
I have tried this way down below but didn't work:
func calendar(_ calendar: JTAppleCalendarView, willDisplayCell cell: JTAppleDayCellView, date: Date, cellState: CellState) {
guard let sfbCell = cell as? SFBCalendarCell else {return}
let booking = self.bookingsMonths[cellState.row()]
if booking.date == date {
sfbCell.dayText.textColor = .red
} else {
sfbCell.dayText.textColor = .black
}
}
I Solved by using Contains method
if bookingsMonths.contains(where: { $0.date == cellState.date && $0.bookings_count != 0 }) {
sfbCell.dayText.font = UIFont.boldSystemFont(ofSize: 15)
} else {
sfbCell.dayText.font = UIFont.systemFont(ofSize: 15)
}