Swift 坚持使用发生日期和生日联系人标识符



我在EKEvent上取得了成功,包括日历标识符,标题,开始/结束时间等...但是我只剩下两个是发生日期和生日联系人标识符。这是我的代码,我卡住了:

if let getbirthday = get_event.birthdayContactIdentifier {
print(getbirthday.description)
}

这将显示联系人标识符,它工作正常,但我如何链接到带有标识符的联系人?

if let getoccurrence = get_event.occurrenceDate {
print(getoccurrence.description)
}

结果显示:

2020-05-30 02:00:00 +0000
2020-05-29 06:00:00 +0000

我不确定为什么它显示 5 月 30 日凌晨 2 点和 5 月 29 日早上 6 点,因为我把晚上 8 点到晚上 10:30,每周重复一次。如何让我的应用知道重复的频率和时间?

感谢您的帮助!

我发现了这个问题。我使用代码:

if let getrecurrence = get_event.recurrenceRules?.first {
if getrecurrence.frequency == .daily {print("daily!")}
if getrecurrence.frequency == .monthly {print("monthly!")}
if getrecurrence.frequency == .weekly {print("weekly!")}
if getrecurrence.frequency == .yearly {print("yearly!")}
}

最新更新