簡體   English   中英

如何在EventKit中使用CalendarIdentifier獲取提醒?

[英]How to fetch Reminder with CalendarIdentifier in EventKit?

在Apple文檔搜索中使用唯一標識符

如果您知道該事件的唯一標識符是因為您以前使用謂詞來獲取它,則可以使用EKEventStore方法event(withIdentifier :)來獲取該事件。 如果是重復發生的事件,則此方法將返回該事件的首次出現。 您可以使用eventIdentifier屬性獲取事件的唯一標識符。

同樣,如果您以前通過謂詞獲取特定提醒的唯一標識符,則可以調用calendarItem(withIdentifier :)實例方法。 calendarItem(withIdentifier :)可以獲取任何日歷項(提醒和事件),而event(withIdentifier :)僅獲取事件。

我的問題是我想獲取EKReminder以使用isCompleted屬性。

 // Mark reminder as completed
 // Use the completed property to mark a reminder as completed
 func complete(_ reminder: EKReminder) {
    reminder.isCompleted = true

    /* Some my customize code */

    // Update the reminder
    self.save(reminder)
}


方法func calendarItem(withIdentifier identifier: String) -> EKCalendarItem? 返回EKCalendarItem。

我不想使用循環來搜索我想要的提醒。 有什么辦法嗎?

EKCalendarItemEKReminderEKEvent的基類。 如果您知道日歷項目是個提醒, EKReminder其投射到EKReminder

let reminder = store.calendarItem(withIdentifier: identifier) as! EKReminder

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM