简体   繁体   中英

Creating EKEvent with Unique Identifier(Not Editable)

I want to create an EKEvent to add it in device calendar. Is there any way to set a unique id (which a user can not edit in Calendar app) to this event so that I can identify or match it with my event.

I am creating event like this

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)
}

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM