FSCalendar icon indicating copy to clipboard operation
FSCalendar copied to clipboard

Could not cast value of type 'FSCalendarCell' to 'DIYCalendarCell'

Open Tim77277 opened this issue 7 years ago • 6 comments

Hi I had hard to the create a custom cell. I followed the example code DIYCalendarCell and basically no any changes. Just add new file that subclass to FSCalendarCell and then paste the code in the DIYCalendarCell and then register the custom cell to the calendar. However it crashes on the line

let diyCell = (cell as! CalendarDateCell)

it says "Could not cast value of type 'FSCalendarCell' to 'DIYCalendarCell' ", but the same code in the example project works properly.

I would appreciate if you can help me on this. Thank you

Xcode version is 8.3.3 FSCalendar version is the latest. Device: Simulator iPhone 7

The following informations are requested in a bug report

  • A brief bug description.
  • Stack trace.
  • Integration method.(manually/cocoapods/carthage)
  • Full steps to reproduce.
  • Device modal and iOS version. e.g. iPhone 6s iOS9.1
  • Xcode version. e.g. Xcode 8.1
  • FSCalendar version. e.g. FSCalenda 2.5.1
  • Does this happen in the demo project? Which one? Or a link to another demo project.

Tim77277 avatar Sep 17 '17 18:09 Tim77277

Hey @Tim77277 I've got the similar problem - did you manage to solve it?

tinaStremenova avatar Jan 23 '18 13:01 tinaStremenova

same issue here.... Please who has figured this out...

effy4u avatar Apr 09 '19 10:04 effy4u

incase you haven't figured this out yet, here is the solution, add this

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

effy4u avatar Apr 10 '19 03:04 effy4u

same issue.. Please give me any solutions ??

Meet-iottive avatar Dec 09 '20 12:12 Meet-iottive

try to import FSCalendar in DIYCalendarCell.swift file than clean and build the project.It solves my error but now app crashes because of did not find identifier "Cell".

pramod7 avatar Jun 18 '21 15:06 pramod7

@pramod7 I'm getting the same issue while registering the cell

infinigent-solutions avatar Feb 27 '23 10:02 infinigent-solutions