- i want to add event on every week in specific day selected by user. it can be one or more or may be all day.
- i'm storing day value selected by user in model class variable.
- But when i adding event and select days suppose today is monday and i select Tuesday and Wednesday and save it. then i check in iphone calendar it added in Monday and Wednesday.
i cant understand this problem, even i debug my code i get right value for day selection in model class variable then why result different ?
Suggest me any solution or idea.
Thanks
var days = [EKRecurrenceDayOfWeek]()
if routineData.routine_monday == 1 {
days = [EKRecurrenceDayOfWeek(.monday)]
}
if routineData.routine_tuesday == 1 {
days = [EKRecurrenceDayOfWeek(.tuesday)]
}
if routineData.routine_wednesday == 1 {
days = [EKRecurrenceDayOfWeek(.wednesday)]
}
if routineData.routine_thursday == 1 {
days = [EKRecurrenceDayOfWeek(.thursday)]
}
if routineData.routine_friday == 1 {
days = [EKRecurrenceDayOfWeek(.friday)]
}
if routineData.routine_saturday == 1 {
days = [EKRecurrenceDayOfWeek(.saturday)]
}
if routineData.routine_sunday == 1 {
days = [EKRecurrenceDayOfWeek(.sunday)]
}
let rule = EKRecurrenceRule(recurrenceWith: .weekly, interval: 1, daysOfTheWeek: days as? [EKRecurrenceDayOfWeek], daysOfTheMonth: nil, monthsOfTheYear: nil, weeksOfTheYear: nil, daysOfTheYear: nil, setPositions: nil, end: nil)
event.addRecurrenceRule(rule)