1

This is the entire extension section of the JTAppleCalendar delegate and datasource methods implementation.

extension ViewController : JTAppleCalendarViewDelegate, JTAppleCalendarViewDataSource {
  func configureCalendar(_ calendar: JTAppleCalendarView) -> ConfigurationParameters {
    // set date formatter
    formatter.dateFormat = "yyyy MM dd"
    formatter.timeZone = Calendar.current.timeZone
    formatter.locale = Calendar.current.locale

    let startDate = Date()
    let endDate = (Calendar.current as NSCalendar).date(byAdding: .day, value: 180, to: startDate, options: [])!

    let parameters = ConfigurationParameters(startDate: startDate, endDate: endDate)
    return parameters
  }
  func calendar(_ calendar: JTAppleCalendarView, cellForItemAt date: Date, cellState: CellState, indexPath: IndexPath) -> JTAppleCell {
    let cell = calendar.dequeueReusableJTAppleCell(withReuseIdentifier: "DateCell", for: indexPath) as! AccountsDateCell
    cell.dateLabel.text = cellState.text
    return cell
  }
}

Xcode is saying:

Type 'ViewController' does not conform to protocol 'JTAppleCalendarViewDelegate'

It looks like the problem is with manual installation of the library. I dragged and dropped the files into this project. Is there any other way to manually add the library to the project?

as diu
  • 1,010
  • 15
  • 31
  • 1
    I know nothing of this library but it looks like you have implemented one data source method and no delegate methods. You need to implement any non-optional delegate and any non-optional data source methods since you declare that you conform to those protocols. – rmaddy Sep 23 '17 at 01:04
  • @rmaddy thanks for replying, as per http://cocoadocs.org/docsets/JTAppleCalendar/7.0.6/Protocols/JTAppleCalendarViewDelegate.html I'm implementing the required non-optional delegate method which is `calendar(_:cellForItemAt:cellState:indexPath:)`. upvoted for reply – as diu Sep 23 '17 at 01:13
  • 1
    XCode 9 should show you a hint of what you are missing when you click on the red error. Can you click on it, then let Xcode insert the missing funciton for you? – Just a coder Sep 23 '17 at 16:29
  • I'm implementing all required delegates. Are you @patchthecode?! Apart from dragging and dropping the files is there any other way to manually add the files to my project? Thank you for replying. – as diu Sep 23 '17 at 22:00
  • 1
    @asdiu yes. i'm patch. You can manually add the files to your project by getting them from github. You'll see a folder called `Sources`. Drag all the swift files in there into your project. Now since youre dragging them manually, you'll get lots of errors until you add -> `#import UIKit` to the top of most of the files. – Just a coder Sep 25 '17 at 15:10

1 Answers1

1

You must implement the configureCalendar(_ calendar: JTAppleCalendarView) -> ConfigurationParameters delegate method.

If you are using Xcode 9, it should offer to insert the required function stubs for you.

Paulw11
  • 108,386
  • 14
  • 159
  • 186