             selectedEventIndex = 0
         }
         
-        delegate.calendarView?(self, didDeselectEventAtIndex: indexPath.item, date: date)
+        delegate?.calendarView?(self, didDeselectEventAtIndex: indexPath.item, date: date)
     }
 }
 

        }
    }
    
    public weak var appearance: YMCalendarAppearance!

    public weak var delegate: YMCalendarDelegate!
    
    public weak var dataSource: YMCalendarDataSource!
    
    public var calendar = Calendar.current {
        didSet {

        var comps = DateComponents()
        comps.day = indexPath.section
        guard let date = calendar.date(byAdding: comps, to: view.referenceDate),
            let shouldSelect = delegate?.calendarView?(self, shouldSelectEventAtIndex: indexPath.item, date: date) else {
            return true
        }
        return shouldSelect
