快速更新EKEvent

问题描述

嗨,我正在尝试更新EKEvent。我已经能够使用相同的逻辑成功添加删除事件。

添加我使用的事件-> try store.save(event,span: .thisEvent,commit: true)

如何更新事件???

删除我使用的事件-> try store.remove(calendar,commit: true)

调用updatedEvent()方法时,我具有正确的EKEvent标识符和EKEvent,并且能够在该函数中打印事件。

调用函数时,它无法更新新事件,并显示“事件无法更新”。

我找不到store.update(event,commit: true)之类的东西。

非常感谢任何帮助!

    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!,commit: true)
            
        } catch {
            print("Event Could not be updated")
        }
    }

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)