我試圖添加一個提醒,它會在每個星期一重複。但我得到以下錯誤:Swift EKRecurrenceDayOfWeek問題
Cannot convert value of type 'Int' to expected argument type 'EKWeekday'
當我添加RecurrenceRule。
在蘋果公司的文檔就指出:
var dayOfTheWeek: EKWeekday { get }
值是從1到7,星期天爲1。
下面是我的代碼,用點錯誤顯示出現。
let reminder = EKReminder(eventStore: eventStore)
let calendarIndentifier = NSUserDefaults.standardUserDefaults().objectForKey("calendarIdentifier")
print("calendar.calendarIdentifier : \(calendarIndentifier)")
reminder.title = "Don't forget to walk the dog!"
reminder.calendar = eventStore.calendarWithIdentifier(calendarIndentifier as! String)!
reminder.priority = 3;
reminder.addRecurrenceRule(EKRecurrenceDayOfWeek(2))
*** error happens here ***
let alarm = EKAlarm(absoluteDate: reminderTime)
reminder.addAlarm(alarm)
我該如何克服這個錯誤?
可以像EKRecurrenceDayOfWeek(.monday)一樣使用,不使用int EKRecurrenceDayOfWeek(2) –