didSelectDate func is not getting called in FSCalendar in Swift

1.5k views Asked by At

I'm trying to get the date that the user selects via the didSelectDate function, but it's not getting called.

Here's my code:

func calendar(calendar: FSCalendar!, didSelectDate date: Date!) {
    print ("this func is getting called")
}

What's the problem?

2

There are 2 answers

0
Tamás Sengel On BEST ANSWER

In Swift 3, the method changed a little. Replace

func calendar(calendar: FSCalendar!, didSelectDate date: Date!)

with

func calendar(_ calendar: FSCalendar, didSelect date: Date)
0
wammy On

Swift 4

func calendar(_ calendar: FSCalendar, didSelect date: Date, at monthPosition: FSCalendarMonthPosition){

     print("date is selected \(self.formatter.string(from: date))"

}