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

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

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