and i set that mutable-array in dayOfTheWeek. see below code.
let tempDays = NSMutableArray()
if routineData.routine_monday == 1 {
tempDays.add(EKRecurrenceDayOfWeek(.monday))
//days = [EKRecurrenceDayOfWeek(.monday)]
}
if routineData.routine_tuesday == 1 {
tempDays.add(EKRecurrenceDayOfWeek(.tuesday))
}
if routineData.routine_wednesday == 1 {
tempDays.add(EKRecurrenceDayOfWeek(.wednesday))
}
if routineData.routine_thursday == 1 {
tempDays.add(EKRecurrenceDayOfWeek(.thursday))
}
if routineData.routine_friday == 1 {
tempDays.add(EKRecurrenceDayOfWeek(.friday))
}
if routineData.routine_saturday == 1 {
tempDays.add(EKRecurrenceDayOfWeek(.saturday))
}
if routineData.routine_sunday == 1 {
tempDays.add(EKRecurrenceDayOfWeek(.sunday))
}
print("day selected\(tempDays)")
let rule = EKRecurrenceRule(recurrenceWith: .weekly, interval: 1, daysOfTheWeek: tempDays as? [EKRecurrenceDayOfWeek], daysOfTheMonth: nil, monthsOfTheYear: nil, weeksOfTheYear: nil, daysOfTheYear: nil, setPositions: nil, end: nil)
event.addRecurrenceRule(rule)
You can define the days as an array of EKRecurrenceDayOfWeek like
let days = [EKRecurrenceDayOfWeek]()
Or you should cast NSMutableArray
to expected argument type [EKRecurrenceDayOfWeek]
let rule = EKRecurrenceRule(recurrenceWith: .weekly, interval: 1, daysOfTheWeek: days as? [EKRecurrenceDayOfWeek], daysOfTheMonth: nil, monthsOfTheYear: nil, weeksOfTheYear: nil, daysOfTheYear: nil, setPositions: nil, end: nil)