1

I am using Swift 2 and JTAppleCalendar Cocoa Pod for building my Calendar in my app.

I am trying to implement the function configureCalendar which is the only function in the protocol JTAppleCalendarViewDataSource.

this is the definition of the function as given by the pod:

func configureCalendar(calendar: JTAppleCalendarView) -> (startDate: NSDate, endDate: NSDate, numberOfRows: Int, calendar: NSCalendar)

This is my implementation:

extension CalendarViewController:  JTAppleCalendarViewDataSource {
    func configureCalendar(calendar: JTAppleCalendarView) -> (startDate: NSDate, endDate: NSDate, numberOfRows: Int, calendar: NSCalendar) {
        formatter.dateFormat = "yyyy MM dd"
        formatter.timeZone = NSCalendar.currentCalendar().timeZone
        formatter.locale = NSCalendar.currentCalendar().locale
        let startDate = formatter.dateFromString("2017 01 01")
        let endDate = formatter.dateFromString("2017 12 31")
        let calendar = NSCalendar.currentCalendar()
        return (startDate!, endDate!, 5, calendar)
    }    
}

I get this error from the compiler:

CalendarViewController.swift:32:1: Type 'CalendarViewController' does not conform to protocol 'JTAppleCalendarViewDataSource'

JTAppleCalendar.JTAppleCalendarViewDataSource:11:17: Protocol requires function 'configureCalendar' with type '(JTAppleCalendarView) -> (startDate: NSDate, endDate: NSDate, numberOfRows: Int, calendar: NSCalendar)'

Why am I not conforming the protocol?

Eyzuky
  • 1,843
  • 2
  • 22
  • 45

1 Answers1

1

fixed it by changing my return statement to look like this:

return (startDate: startDate!, endDate: endDate!, numberOfRows: 5, calendar: calendar)
Just a coder
  • 15,480
  • 16
  • 85
  • 138
Eyzuky
  • 1,843
  • 2
  • 22
  • 45