0

Hi I am trying to update an EKEvent. I have successfully been able to add and delete an event by using the same logic.

To add Event I used -> try store.save(event, span: .thisEvent, commit: true)

How do I updated Event ???

To delete Event I used -> try store.remove(calendar, span: .thisEvent, commit: true)

I have the correct EKEvent Identifier and EKEvent when the updatedEvent() method is called, and I am able to print the event in that function.

When this function is called it fails to update the new event, and prints "Event Could not be updated".

I could not find a store.update(event, span: .thisEvent, commit: true) or something along the lines of that.

Any help is much appropriated thanks!

    public func updateEvent(title: String, startDate: Date, isAllDay: Bool , timeZone: String,address: String, note: String, store: EKEventStore, event: EKEvent){
        

          let event = store.event(withIdentifier: event.eventIdentifier)
          let endDate = startDate.addingTimeInterval(2 * 60 * 60)
            event?.title = title
            event?.isAllDay = isAllDay
            event?.location = address
            event?.startDate = startDate
            event?.endDate = endDate
            event?.notes = note
            event?.calendar = store.defaultCalendarForNewEvents
        
        do {
           
            try store.save(event!, span: .thisEvent, commit: true)
            
        } catch {
            print("Event Could not be updated")
        }
    }
Asperi
  • 228,894
  • 20
  • 464
  • 690
  • The `save` updates modified event. – Asperi Sep 15 '20 at 03:47
  • actually tiring to do the exact same thing but i am unable the get the eventIdentifier correctly and store it to Realm. Did you manage to solve it. I am very interested in solving this also. – Rasvan Oct 22 '20 at 16:31

0 Answers0