   
   // MARK: DayViewDelegate
   
+  private var createdEvent: EventDescriptor?
+  
   override func dayViewDidSelectEventView(_ eventView: EventView) {
     guard let descriptor = eventView.descriptor as? Event else {
       return

    }
    print("Creating a new event")
    dayView.create(event: event, animated: true)
  }
  
  override func dayView(dayView: DayView, didUpdate event: EventDescriptor) {

      event.commitEditing()
    }
    
    if let createdEvent = createdEvent {
      createdEvent.editedEvent = nil
      generatedEvents.append(createdEvent)
      self.createdEvent = nil
      dayView.cancelPendingEventCreation()
    }
    
    dayView.reloadData()
  }
}
