         let endDate = dateFormatter.date(from: "2016-12-31")
         let calenderIdentifier = self.userDefaults.string(forKey: "EventTrackerPrimaryCalendar")
         let calendar = self.eventStore.calendar(withIdentifier: calenderIdentifier!)
-        let eventPredicate = eventStore.predicateForEvents(withStart: startDate!, end: endDate!, calendars: [calendar!])
-        events = eventStore.events(matching: eventPredicate).sorted(){
+        let eventPredicate = self.eventStore.predicateForEvents(withStart: startDate!, end: endDate!, calendars: [calendar!])
+        self.events = self.eventStore.events(matching: eventPredicate).sorted(){
             (e1: EKEvent, e2: EKEvent) -> Bool in
             return e1.startDate.compare(e2.startDate) == ComparisonResult.orderedAscending
         }
+        tableView.reloadData()
+    }
+    
+    func addNotification() {
+        NotificationCenter.default.addObserver(self, selector: #selector(ViewController.storeChanged(_:)), name: NSNotification.Name.EKEventStoreChanged, object: eventStore)
+    }
+    
+    func storeChanged(_ nsNotification: NSNotification) {
+        // print("Method invoked")
+         print("Event name \(nsNotification.userInfo?["EKEventStoreChangedObjectIDsUserInfoKey"])")
     }
     
     func getDateFormatter() -> DateFormatter {

extension ViewController: EKEventEditViewDelegate {
    
    func eventEditViewController(_ controller: EKEventEditViewController, didCompleteWith action: EKEventEditViewAction) {
        self.dismiss(animated: true, completion: nil)
    }
    

        })
    }
    
    func loadEvents() {
        let dateFormatter = DateFormatter()
        dateFormatter.dateFormat = "yyyy-MM-dd"
