使用 setPositions 创建 EKRecurrenceRule
Create EKRecurrenceRule using setPositions
问题的简单版本:
如何使用 setPositions
字段创建 EKRecurrenceRule 对象?
较长版本的问题:
我在我的应用程序中使用以下代码创建了一个带有 EKRecurrenceRule
对象的事件:
let recurrenceRule = EKRecurrenceRule(recurrenceWithFrequency: .Yearly ,
interval: 1,
daysOfTheWeek: [EKRecurrenceDayOfWeek(.Friday)],
daysOfTheMonth: nil ,
monthsOfTheYear: [8, 9, 10, 11, 12],
weeksOfTheYear: nil,
daysOfTheYear: nil,
setPositions: [-1.0],
end: nil)
在我的应用程序中创建事件后,内置日历中的输出如下所示:
如您所见,setPosition
的读数为零。但奇怪的是,我可以在我的应用程序中输出 recurrenceRule
对象的 setPosition
属性 并获得我设置的 -1
的值,如下所示:
if let setPosition = recurrenceRule.setPositions?[0]{
print("event set position: \(setPosition))")
} else {
print("event set position: nil)")
}
当使用内置日历创建具有完全相同递归的事件时,输出看起来符合预期:
但是当我运行在内置日历中创建的事件上输出与上面相同的代码时,setPositions
输出nil
。
let recurrenceRule = EKRecurrenceRule(recurrenceWithFrequency: .Monthly ,
interval: 1,
daysOfTheWeek: [EKRecurrenceDayOfWeek(.Friday)],
daysOfTheMonth: nil ,
monthsOfTheYear: [8, 9, 10, 11, 12],
weeksOfTheYear: nil,
daysOfTheYear: nil,
setPositions: [-1.0],
end: nil)
在 "monthsOfTheYear" 中提到的月份,每月会为您提供一次服务。您目前拥有的是一年一次
问题的简单版本:
如何使用 setPositions
字段创建 EKRecurrenceRule 对象?
较长版本的问题:
我在我的应用程序中使用以下代码创建了一个带有 EKRecurrenceRule
对象的事件:
let recurrenceRule = EKRecurrenceRule(recurrenceWithFrequency: .Yearly ,
interval: 1,
daysOfTheWeek: [EKRecurrenceDayOfWeek(.Friday)],
daysOfTheMonth: nil ,
monthsOfTheYear: [8, 9, 10, 11, 12],
weeksOfTheYear: nil,
daysOfTheYear: nil,
setPositions: [-1.0],
end: nil)
在我的应用程序中创建事件后,内置日历中的输出如下所示:
如您所见,setPosition
的读数为零。但奇怪的是,我可以在我的应用程序中输出 recurrenceRule
对象的 setPosition
属性 并获得我设置的 -1
的值,如下所示:
if let setPosition = recurrenceRule.setPositions?[0]{
print("event set position: \(setPosition))")
} else {
print("event set position: nil)")
}
当使用内置日历创建具有完全相同递归的事件时,输出看起来符合预期:
但是当我运行在内置日历中创建的事件上输出与上面相同的代码时,setPositions
输出nil
。
let recurrenceRule = EKRecurrenceRule(recurrenceWithFrequency: .Monthly ,
interval: 1,
daysOfTheWeek: [EKRecurrenceDayOfWeek(.Friday)],
daysOfTheMonth: nil ,
monthsOfTheYear: [8, 9, 10, 11, 12],
weeksOfTheYear: nil,
daysOfTheYear: nil,
setPositions: [-1.0],
end: nil)
在 "monthsOfTheYear" 中提到的月份,每月会为您提供一次服务。您目前拥有的是一年一次