[英]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。
我不想使用循環來搜索我想要的提醒。 有什么辦法嗎?
EKCalendarItem
是EKReminder
和EKEvent
的基類。 如果您知道日歷項目是個提醒, EKReminder
其投射到EKReminder
let reminder = store.calendarItem(withIdentifier: identifier) as! EKReminder
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.