gpt4 book ai didi

ios - 如何定义 EKRecurrenceRule 来表示 'Every 4 years only on 4th of July'

转载 作者:行者123 更新时间:2023-11-29 00:42:28 24 4
gpt4 key购买 nike

我试图表示重复规则,

Every 4 years only on 4th of July.

像这样:

termin.addRecurrenceRule(EKRecurrenceRule(recurrenceWithFrequency: .Yearly,
interval: 4,
daysOfTheWeek: nil,
daysOfTheMonth: [NSNumber(int: 4)],
monthsOfTheYear: [NSNumber(int :7)],
weeksOfTheYear: nil,
daysOfTheYear: nil,
setPositions: nil,
end: nil))

但是 Apple 文档说:

daysOfTheMonth: The days of the month that the event occurs, as an array of NSNumber objects. Values can be from 1 to 31 and from -1 to -31. This parameter is only valid for recurrence rules of type EKRecurrenceFrequencyMonthly.

那么如何用 EKRecurrenceRule 类表示上述规则?

注意:答案可能在 Swift 或 Objc 中。

最佳答案

创建一个开始日期和结束日期为 7 月 4 日的事件,并为其指定每年重复规则,如下所示:

let event = EKEvent(eventStore: self.eventStore)

event.title = title
event.startDate = fourthOfJulyStartDate
event.endDate = fourthOfJulyEndDate
event.recurrenceRules = [EKRecurrenceRule(recurrenceWithFrequency: .Yearly, interval: 4, end: nil)]

关于ios - 如何定义 EKRecurrenceRule 来表示 'Every 4 years only on 4th of July',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39118538/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com