Why EKWeekday fails to return nil when initialising with incorrect value

17 Views Asked by At

I have notice that EKWeekday can be initialised with incorrect value, and it is not returning nil.

let weekDayInt = 10
guard let weekDay = EKWeekday(rawValue: weekDayInt)  else { return }
let recurrence =  EKRecurrenceDayOfWeek(weekDay)

when initialising the EKWeekday with incorect value it not return nil but when I try to use that value to create a new EKRecurrenceDayOfWeek it crashes with Invalid day number

is there any other way to validate the correctness of value besides validating weekDayInt <= 7 && weekDayInt >=1

0

There are 0 best solutions below