[英]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
讀取為nil。 但奇怪的是,我可以在我的應用程序中輸出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”中提到的幾個月里,你會每月一次。 你現在擁有的是一年一次
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.