使用唯一标识符创建EKEvent(不可编辑)

时间:2018-10-24 10:58:14

标签: ios swift ekevent ekeventstore

我想创建一个EKEvent以将其添加到设备日历中。有什么方法可以为此事件设置唯一的ID(用户无法在“日历”应用中编辑该ID),以便我可以将其标识或与事件匹配。

我正在创建这样的活动

let event = EKEvent.init(eventStore: eventStore)
event.title = "My location"
event.location = "Location Address"

// Setting Start - End Date
event.startDate = Date()
event.endDate = Date()

do {
    // Saving Events
    try eventStore.save(event, span: .thisEvent, commit: true)
    let message = "Schedule has been added to your device's calendar."
    showAlert(title: kFVApplicationTitle, message: message)
} catch {
    let message = "Schedule could not be added to your device's calendar."
    showAlert(title: kFVApplicationTitle, message: message)
}

1 个答案:

答案 0 :(得分:0)

为EKEvent创建类别并在其中添加其他属性可以解决我的问题。